In Part 1, you wrote down the value unit tests (not TDD, unit tests) bring you, and the pains they cause you.
In Part 2, You also found the white whale in your code base, the part of the system that gives you fits when you try to unit test it, and you figured out its cyclomatic complexity.
Today, we’re going to ask one final question, and then we’ll be ready to tackle this part of the code-base.
Is that part of the code-base important to your customer or business?
In other words, if your code-base was a house you’re trying to sell, is what you’re looking at the Living Room or the utility closet?
Both are important, but for different reasons.
The Living Room must be pristine. It must always be in a showable condition. It will set the tone for the rest of the house. After all, the buyer is going to *live* in that room (it is called a living room for a reason).
The utility closet, on the other hand, need not be showable, and often never is. “Oh, that’s the utility closet”, and the prospective buyer may peek in, but they’re not going to study it, apart from “Does this work”, they don’t care how it looks.
Now, you and I both know the Utility closet is important. Last July, under a sweltering heatwave, my 20+ year old furnace finally gave out, and to make matters worse my AC system used the old style refrigerant which has been banned from sale and is a year or two away from the secondary market being closed, meaning it would get tougher (to border on impossible) to find replacement refrigerant should I need to do that. So I paid to have the whole thing replaced. Condenser, AC Unit, and Furnace (as well the Hot Water heater — it too was on its last legs).
I had figured this was coming, but I hadn’t put resources to fixing it, until it was too late.
And by the time it was too late, it cost me $11,136 (USD) to fix.
Anyway, back to our analogy.
If the part of the system you’re looking at is the utility closet; you have to change how you pitch fixing it to your business stakeholders than if it were the living room.
The financial impact of your utility closet going down is high, typically, and the financial impact of a latent problem is also high.
The reputational impact of your living room developing a hole in the ceiling is high, but the fix can be low cost (Not a serious suggestion but putting a bucket in the attic would patch the problem).
As a software developer, those are the two levers you can pull that have merit to a business person: The reputational impact of a bug due to the nature of the code that is UI visible; or an actual “We’re down and we don’t know why” bug to code that lives in your utility closet.
Better companies, of course, will understand the “long term maintenance” argument for keeping code under test; but just because they understand it, doesn’t mean it crosses their radar that making code easier to test should be an activity developers do.
So, determine if that code you’ve identified as your white whale is in the living room of your software project, or the utility closet, and next time we’ll make use of that information to help our business and our code-base get better.