

Reduce Technical Debt Part 3 – Test driven code and PBI tasks
source link: https://blog.coates.dk/2020/04/20/reduce-technical-debt-part-3-test-driven-code-and-pbi-tasks/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.


Reduce Technical Debt Part 3 – Test driven code and PBI tasks
In this blog post I am going to outline how test-driven design/unit test and having a code removal task for each Product Backlog Item (PBI) can help reduce technical debt.
If you have not already done so, please read part 1 and part 2 in this series on reducing technical debt, as they set the scene for what this blog post is trying to address.
Test-driven design/unit test
It is a fact that all developers (myself included) tend ignore and not correct/change comments when modifying code. Therefore, test driven code will reduce technical debt!
Unit tests decoratively define what code should do and are especially useful in describing exceptions, that would otherwise lead to miss understandings.
I could go on all day about the virtues of test drive design! But I am only going to focus on how it can help reduce technical debt by describing exceptions and or confusing code.
Unit Test for exceptions and or confusing code
We have all come across code where we think WTF! and then spend hours refactoring and or trying to determine why it does what it does.
For example, In France certain types of furniture have a different VAT rate a Chaiselong and a sofa have a different VAT rate.
Therefore, having a test call EnsureChaiselongAndSofaHasdifferentVatRateInFrance will help explain/document why this complexity and or strange functionality is in the code.
Now whilst it does not directly reduce the technical debt and or code size, it helps explain this code and therefore reduce the cost to maintain the code.
Having a test that confirms the strange code is in fact correct and required and why it is required has value and will reduce maintenance code and future bugs.
How do you ensure that each PBI raises the quality of the code?
Ensure that there is a code removal task for each Product Backlog Item.
This ensures that everyone involved in the project is aware that it takes time to identify and then remove redundant code and it is an essential part of all new development/modifications.
There should always be a task defined for every PBI even where it is 100% new functionality and there is defiantly no redundant code to be removed.
Therefore, the premise is that the team must prove and establish for every PBI that there is no redundant code.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK