What nobody told you about writing testable code

Managing Software Unpredictability improves your tests

Ikechi Michael
2 min readMar 17, 2023

You know how when you sweep a room, you’re gathering dust into one corner of the room, so you can manage it easily?

Like there’s nothing stopping you from iteratively moving dust into the dustpan for each square foot of the room, if you’re so inclined? It’s just a lot, lot harder to do with a broom.

It’s the same way we manage unpredictability in software code where unpredictability is the dust we are trying to sweep, and making dependencies explicit is the act of sweeping unpredictability into a corner so it can be easily managed.

Read Full Article in Notion

Unpredictability and chaos has the bitter enemy of humanity since man encountered nature and every surprise usually meant doom unless it could be foreseen. Because software is ultimately built for humans, predictability is indeed an important aspect of software quality. You want your software to be predictable, so if a function returns “1” today, it should continue to return "1" on a leap year, blue moon, or during the 13th lunar month.

Writing testable code helps ensure that the behavior of your software is consistent and predictable, and it is the goal of this article, to show how understanding dependency trees and making dependencies explicit, can be harnessed to write testable software. We explore the concepts of explicit and implicit dependencies with examples, and show the problems caused by implicit dependencies.

Read Full Article in Notion

--

--

Ikechi Michael

I’ve learned I don’t know anything. I've also learned that people will pay for what I know. Maybe that's why they never pay.