I have been coding for some years now, and I have learned a lot the last couple of years. One of the most useful term I have picked up is the term Technical Debt. This weekend have been a reminder of how high the interest rates of technical loans really are.
Back in 2005 I wrote a complete CMS in ASP.NET for the company my mother and step-father owns. I had never done ASP.NET before, and design patterns was not something I cared to much about. The result was a working site! I learned a lot about .NET, C# and ASP.NET. I can remember how satisfied I was about the site. It boats multiple language support, automatic barcode generator and loads of cool features. Job well done!
This weekend my impression changed. I had to revisit the codebase; there were some new requirements, another thing I have learned to be inevitable. So I fired up Visual Studio knowing that this would get ugly, but I never thought it would be this bad. While trying to read the code I had to shake my head in frustration over 2005-me. The list of horrifying properties of the codebase includes but is not limited to
- No models
- No separation what so ever
- Zero tests – and also, no documentation
- Virtually unreadable code with methods the size of the Amazon River
Among my findings was a single method counting 150 lines of compact code. This was done directly in the code behind, of course, and the whole thing is sprinkled with direct calls to the database. The SQL queries were just as bad, and string.Format was not yet discovered. I must admit that my brain shouted “Redesign!” a couple of times, but I managed to shut it up and dive into the “code”.
It took me about 2 hours to get to the point where I knew what to do with the code to implement the new feature. It took another hour to identify the parts of the site that would be affected by the changes I were to make. I can’t help but feel a bit sorry for past-me. He didn’t know any better, so I guess he’s excused. But I am stuck with paying for his inexperience with my precious time, and so this whole post is a BIG NOTE TO SELF:
Dear self,
please minimize technical debt. Write clean code. Write tests. Don’t borrow time from the codebase unless you have no other choice. And if you do, pay it back as soon as possible. Someone will have to pay, and the longer it takes, the bigger the interest overhead gets. The result of long term technical debt is net loss of time. Time is a scarce resource; please minimize technical debt.
Good post! This is a very valuable experience!
Ole Gunnar
Excellent post.
The sign of a developer that is improving is a developer that looks at old code they wrote and thinks “christ, this is terrible, I could do it so much better today.”
Some developers don’t think that: they see their old, sloppy code and carry on hacking away at it in the same fashion they always did.