day 8

Working with third-party code

I started preparing to retrieve album information today. Logging in with Spotify is working well and I need to figure out how to reconnect when needed to in order to do things besides just log in.

The rspotify gem I’m using provides a way to do just this. Store the object in a hash and re-constitute it as needed when I want to reconnect. The upside of using a library like this is to offload things like refreshing access tokens and provide a nice way to get the data I want. Should save time. The downside is having to dig into unfamiliar code if there are problems.

Unfortunately, I’m running into a problem. Once I recreate the rspotify object, I’m getting an error when trying to pull album data. Hopefully it’s just an error on my part with how I’m using the library. I’ll revisit tomorrow and see if I can figure it out. If not, I may have to abandon ship and either try another gem or connect to the API directly.

Be careful when choosing third-party code to add to your application. It’s easy to get into a situation where it’s costing you more time than it’s worth. On the other hand, you don’t want to fall into the trap of having to building everything yourself and not benefitting from using the tools that are available to you. So try out libraries, but just remember that there may be hidden costs involved. With experience, you’ll develop a sense of which projects are long-lived and stable enough to trust.