When rapid development slows down productivity —a talk about maintainability
In an ideal World, writing code fast gets things done quickly, and make developers productive. Unfortunately, this is not true for many long term projects, and the reason is in a simple chart.
The larger part of development time is spent on maintenance, while the first implementation is just a small fraction.
Examples
To write code faster, we developers tend to use practices such as:
- Copy and paste
- Patchy, append-only code
- Shortcuts from conventions and coding principles
- Abuse of hacks, magic code, blurry operators, one-liners
Maintainable code, on the other hands, requires:
- Refactoring, sometimes even preemptive
- Defensive programming, decoupling, cohesion, consistency
- Unit testing, integration testing, eventually end-to-end testing
- Making the code easy to read, not necessarily clever or shorter
If quick coding helps deliver faster, in the long term the lack of maintainability can offset any benefit and slow down the development
Software immobility
Poor code will lead, earlier or later, to software immobility.
With software immobility, the code becomes resilient to change. Common symptoms that can suggest the issue are:
- Silly bugs in production
- Fix one bug, and another one appears
- Same kind of bugs over and over
- Resiliency to change architecture by developers
Maintainability tradeoff
If rushed development is not always ideal, even the opposite approach can be economically counterproductive. After all, writing high quality, maintainable code also implies development costs.
The lower the quality, the higher the costs. The higher the quality, the higher the costs.
There is an ideal level of quality, which depends from application to application.
If the application is trivial, quick coding practices can reduce costs. When the application is complex and mission-critical, high-quality code is more favorable.
Most of the applications are between those limits, and ideally, should adhere at least to common concepts of code quality, such as:
- Decoupling and cohesion
- Defensive programming
- Reuse of code
- Readability