The Sauce of Technical Debt
The world is full of bad analogies, let’s make another one
A lot has been written about Technical Debt since it’s inception in 1992 — yes, technical debt is now officially 2⁵ years old. A lot of has been understood about technical debt since then — I particularly like Martin Fowler articles on the topic. And lot has also been misunderstood. I still repeatedly hear the questions like:
- can you show me the technical debt?
- how do you know there is technical debt?
- why did you make it in the first place?
- can’t you just delete it?
- so, you wrote it badly at the beginning?
- if you get rid of it now, it will be gone forever, right?
- why didn’t you write it so that there is no technical debt?
Some people say that computer programs are just algorithms and algorithms are just like cooking recipes. Which is sort of true. All of that magic complicated nerdy stuff is but a simple list of steps. One can just follow them and cannot make a mistake. Sort of.
Let’s assume you have a grandmother and she does the best Hollandaise Sauce ever. A sauce that has no match on the planet (or at least the part you know).
One day you ask your Grandmother to give you a recipe for her Hollandaise Sauce and she writes you something like this:
1. mix white wine or tarragon vinegar and 2 egg yolks+salt
2. whisk for a few minutes
3. heat and whisk for a few more minutes until thick
4. add melted butter until it's creamy + lemon
She teaches you how to actually do it, and you too learn to make a great Hollandaise Sauce™. You do it for yourself and a few friends and then more friends and all like it very much. So, one day you make the big decision and open a bistro with a couple of friends and there you serve various dishes with you great Hollandaise Sauce™.
Your grandmothers’ recipe is hanging laminated in a gold coated frame over the open kitchen. The biggest treasure of them all.
You’re very proud of the recipe and of the legacy and the Grandma and all is great.
Except.
You quickly realize that you cannot be the only cook in the bistro forever. You hire another cook. Suddenly the other user of the recipe finds the recipe somewhat unfinished and incomplete. You have to improve the recipe a bit so that it will always behave the same — no matter which user of the recipe is working with it. So you take a permanent marker and quickly make some minor innocent improvements to the laminated treasure:
Now the recipe works like a charm until the other cook leaves for pastures greener and you have to hire a new one. Another user of the recipe comes in. Only then you discover that there are still some things which are not completely foolproof for all recipe users. Also, since the bistro got really busy, you established the practice of having a prepared spice mix to follow the recipe quicker.
Time flies like an arrow, half a year has passed. You now have a lot of customers and little time to actually cook. You add another cook and the two cooks can’t sort of agree how some details of the Treasure should be interpreted.
There is really no time to printout and frame a new recipe. Also the golden frame got a bit dusty and you want to clean it properly. When you have a bit of free time of course. Anyway, that cook strife needs to be sorted out right here, right now, so you take a permanent marker and again quickly fix the recipe.
Business is booming like firework on the Fourth of July. You are now expanding the bistro to create another branch and don’t have so much time to cook at all. You hand over the recipe to the cooks and hope for the best.
And they are doing their best. They are fixing the obvious blind spots of the recipe so that the sauce will always reliably come up as the great Hollandaise Sauce™ and not as McMediocre’s Hollandaise Sauce®. You also realize that you were the only one knowing how to prepare the spice mix and suddenly the recipe is more dependent on you then before you made that optimization.
Oh! What a sad look at the revered Grandmas’ recipe. When you see that, you immediately realize that:
a) the recipe cannot be really “improved” any further — there is just no space left in the frame;
b) although the modifications were mostly to make the life of the users easier — altogether, they’re really making the recipe very difficult to use.
Something must be done about this.
A term commonly associated with technical debt is refactoring. Refactoring means changing the form without affecting the function. It means that you take what you have now and write it from scratch (or nearly so). That doesn’t mean developing the recipe from scratch, but just rewriting it. The point of refactoring is to lose all the accumulated changes (and mistakes) but keep the accumulated knowledge. Let’s refactor the recipe.
It looks quite nice now. But how did this hell happen in the first place? Where did it break?
The answer is “with the first innocent edit”. According to Martin Fowler's classification, the technical debt in this story would start in:
- Reckles-Inadverent quadrant (i.e.: “I’m just making a innocent adjustments, what’s the worst thing that can happen?”)
- and moved to Prudent-Deliberate quadrant (“Ok, we really cannot stop and rewrite it know, we have to move quickly”)
It’s also interesting to ask another question. Why did this happen?
It happened because the recipe was used. Would it have been locked in a grandmas’ closet, nothing would have happened to it. That means that something being old does not necessarily mean that it has technical debt and must be rewritten. Also it’s not just that the thing was being used — if you were the only user of the recipe, not much would have happened to it either. So it’s being used under changing conditions that’s the source of creating and accumulating technical debt.
There are some interesting properties to the new recipe:
- it works exactly the same as before — it’s still the old Grandmas’ recipe,
- it is better structured,
- it is easier to read,
- it is longer (funny thing, because many people have “easier to read” associated with shorter text),
- it took some time to made with “seemingly” no improvement of the recipe,
- there is no direct business gain, your sauce won’t be better, there won’t be more people coming to the bistro,
- there are no ad-hoc modifications done with permanent marker and grandma square pants photo is clearly visible.
So, I hope you liked my bad analogy. And hold your grandparents close to your heart.