Error Control Flow

With a lot of languages nowadays it’s possible to pull together an app pretty quickly, with only a few lines of code. So a newbie developer starts to wonder why all these older devs bemoan the time it takes to make something. Wonder why their apps are filled with tonnes of seemingly superfluous code. And it’s all to do with bloody errors.

I wrote an initial skeleton for an importer today. Just parse a CSV, fetch a few things from remote APIs and then sync it with a database. Simple. It was maybe 100 lines of code.

Then I added in code to check the file encoding of the CSV. And to check the format of the CSV fields. And to handle rate limiting and retries against the API. And to report missing entities from the responses. And to normalize the data for the table schema. And finally to just log everything that happened.

Those one hundred little lines are lost amongst the greater picture. Oh sure, a lot of it can be handled via exceptions and encapsulation. The API wrapper will automatically try a redirect, but that’s more code that has to be written.

90% of writing a program is inputting data, processing data and storing data. The other 90% is dealing with the fact that life never gives you a perfectly-formed, UTF-8 encoded, integrity-checked CSV.