Technical Debt
Escaping the Technical Debt Cycle
A talk by Michael Feathers: Escaping the Technical Debt Cycle
In the talk, he urges against most numeric metrics. He praises the Open/Closed Principle as one important way to avoid adding unhealthy debt:
In object-oriented programming, the open/closed principle states “software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification”; that is, such an entity can allow its behaviour to be extended without modifying its source code.
Bob Martin defines it more clearly:
You should be able to extend the behavior of a system without having to modify that system.
The rest of SOLID can also be helpful, but Feathers spoke most about Open/Closed.
He recommended refactoring code to make adding the new feature easy, rather than just modifying the code for the new behavior.
Single responsibility principle seems closely related: techniques for solving open/closed can also help with SRP. By providing an extension point, you keep a class or function focused on a single responsibility and allow the other responsibility to be injected in an open manner.
Single responsibility principle is broken in a lot of tech debt laden code. Code that changes together belongs together.
This video about SRP by Uncle Bob is a good explanation of the issues and the way to think about SRP.