Robert Martin wrote an article called Principles and Patterns in which he lists the 4 signs of code rot - rigidity, fragility, immobility and viscosity. In the past few years, I've been giving a lot of thought to this article and would propose changing these signs of code rot a bit.
Basically, I want to know "What are the underlying problems we would want to fix in a design". Assuming that the code actually works, on what grounds would we justify doing a refactoring? I've come up with five reasons (three of which overlap with Robert Martin's).
- Rigidity - A small change to the design requires wide-sweeping changes to the code. I also call this the "Local Change, Local Effect" principle.
- Fragility - A small change in one spot causes many things to break
- Immobility - Code is difficult to reuse in contexts other than the original one
- Obscurity - The code is difficult to read and understand
- Dispensability - The code is redundant or not needed at all
The interesting thing I've found is that I can map all of the code smells from Martin Fowler's book on Refactoring to one or more of these 5 signs of code rot. I think they form a good underpinning and justification of object oriented principles and practices.
This observation is one of the main themes of the Refactoring Object Oriented Designs course I'm offering over the spring and summer through XIA Systems.