Dependency injection

A large part of my early maintenance of Podcast Chapters was removing various dependencies. From package managers and external scripts to permissions and, of course, third-party libraries. I was eventually very successful in this, ending up with an app where I depended only on the Mac platform, and where I had learned a lot about all the inner workings of everything the app did.

With the latest version, uploaded and released yesterday, I began to make use of some third-party code again. It amuses me a bit just how strong my initial aversion was, and I am happy I got over it for good reasons.

My library aversion mainly comes from a feeling that I, as the creator of an app, should know the inner workings of my creation really well. If I know well how things work, I should be able to code appropriate solutions for problems. If I do not, I should learn to understand better, then code myself. If I do not understand a problem well enough to solve it myself, I also can not expect a third-party library to solve it for me. I just do not know the risks and trade-offs well enough. And if the library ever breaks or otherwise stops solving the problem for me, I have not moved an inch forward.

I am also hesitant about the sheer mass of code I take on. I would not want to take in a huge library to solve what should be a small problem.

So, in the latest version, I added support for import of data using CSV files. A user might enter all their podcast information in, say, Excel or Numbers, save the spreadsheet as CSV and simply drag and drop the file onto Podcast Chapters to fill in all the information at once. Very nice.

It gradually dawned on me that CSV handling was a good candidate for using a library:

I ended up using Swiftcsv for my CSV parsing needs. Because it is small and light, I added it in the most old-school of ways: by copying the source files into my project. The problem is solved, and the code base is small enough that I could maintain or update it for my needs if I ever needed to.

(I also learned about adding Credits.rtf to my project to get acknowledgement of my usage into Podcast Chapters' about box. Just the way I wanted it.)

The whole exercise also made me curious as to how exactly the solution we built back in the Dark Ages worked. I think we did everything in our own code that time, and I do recall reading up on various edge cases to make sure they worked properly, but I have no recollection of what our actual solutions were. If I saw them today, would I recoil in horror, or be amazed at just how clear-eyed we were? Smart money would be on the first option, but who knows?

I think I could still find that code if I really wanted to …