Writing Maintainable Software
In many software projects, developer productivity reduces over time as it becomes difficult to add features. Maintainable software is easy to change and extend. Writing maintainable software requires a mindset shift, from writing software that works to writing software that works and easy to change.
Refactoring is a tool for writing maintainable code. It involves moving parts of your program around and renaming others. You can unknowingly introduce bugs during this process if the code is not covered by tests. To refactor confidently, test your code. Writing tests feel counter intuitive because it takes more time to get things done right now but remember, the goal is to optimise for future speed.
It is hard to change incomprehensible code, so write readable code. Avoid variable names that are cryptic and meaningless. If your colleagues don’t understand your code, they’ll be tempted to invent hacks to add features. Hacks beget hacks and the software becomes rigid and hard to change.
Software with a lot of dependencies is hard to change and extend. A symptom is when changing one area affects another seemingly unrelated part. This instills fear of modifying the software and results in, if it works don’t change it mentality. Needless to say, the software becomes layers of cruft. Programming to an interface instead of implementation minimises dependencies.
Software that is tested, easy to read and has minimal dependencies is maintainable software.