On Code And TypesAnd saving a bit of my sanityDecember 8, 2022
Photo by Daniel Frank from Pexels
I'm already imagining my supervisor telling me to stop being a perfectionist. 🤣
But here's the thing. Ensuring that the data is using the correct types doesn't just spot bugs ahead of time. It can also help with productivity, reduce tech debt and code quantity. For example, dates can be stored and passed around as strings (e.g. ISO format) or an number (a timestamp). But once you start consuming that date, like getting the year, you now have to do the type conversions manually and everywhere, probably put a converter function in a "utils" package that nobody knows about. But if it were a date begin with, you can just call
date.getYear() right away.
So get your types right. A little effort now can save you your hair and sanity in the long run.
PPS: I know that I write only when I have something to complain about. Taking advantage of the situation to get myself to write something this time. Maybe go back to the usual monthly cadence next year.