This first appeared on my blog. It's the practical reading I would give a backend team after reviewing the research on how maintainable code affects defects, delivery time and technical debt.
Most of the time I spend as a backend engineer is not writing a new service from scratch. It is changing one that already exists: a new discount rule, a different payment provider, a bug in a class that does too many things. That is how long-lived software works.
Lehman's study of evolving systems put it plainly. A program that lives in the real world must keep being adapted, or it becomes less useful, and its complexity tends to grow unless someone works to contain it (Lehman, 1980). The dominant activity across a system's life is changing existing code. How easy that change is — the system's maintainability — decides how long the system stays worth running, and how productive the people on it can be.
In day-to-day work, maintainability is often treated as a matter of taste: something engineers argue for and product managers trade away under schedule pressure. I wanted a clearer answer than taste, so I wrote a narrative literature review of 23 peer-reviewed papers and standards, from Parnas in 1972 through to the Code Red study in 2022. It does not report new experiments. A public PDF is not up yet; this post is the practical reading I would give a backend team. The short version: poorer maintainability is consistently associated with more defects, slower and less predictable delivery, and developer time lost to technical debt. Refactoring and code review help, but only when they are practised in particular ways.
Why this is not just a style debate
ISO/IEC 25010 treats maintainability as a top-level product quality characteristic: the capability of a product to be modified effectively and efficiently. The 2023 edition breaks that into modularity, reusability, analysability, modifiability and testability — questions I can ask of a Spring Boot service. If I change this class, what else breaks? Can I tell what this method does? Can I test the change in isolation?
Cunningham's metaphor still helps: shipping code that does not reflect the team's best current understanding is like borrowing money. It can be the right call, but unpaid debt accrues interest on every later change (Cunningham, 1992). A lot of that interest is invisible to people outside the team (Kruchten, Nord and Ozkaya, 2012).
Parnas's answer, from 1972, is still the one I reach for: hide each decision that is likely to change behind a module boundary, instead of splitting the system by the steps of a processing flow (Parnas, 1972). In Spring Boot, that usually means thin controllers, and interfaces around persistence, payment providers and pricing rules.
What the research actually shows
These are not my measurements. They come from the studies in the review. Most of the work is observational, so I treat the figures as strong associations, not proof that messy code is the only cause.
Low-quality code has far more defects, and they take longer to fix
The clearest business numbers I found are from Tornhill and Borg's Code Red study. They looked at 39 proprietary production codebases and activity in 30,737 files. Low-quality code contained 15 times more defects than high-quality code. Resolving issues in that code took, on average, 124% more development time. Maximum cycle times were up to nine times longer (Tornhill and Borg, 2022).
That last point is easy to miss: a team working in unhealthy code does not only deliver later, it also finds it harder to make a commitment it can keep.
Technical debt wastes a large share of the week
Besker, Martini and Bosch asked developers, repeatedly, how they spent their time, then followed up with interviews. On average, developers reported wasting about 23% of their development time because of technical debt. Existing debt often forced them to take on more, and the most common extra activity was additional testing (Besker, Martini and Bosch, 2018).
Ernst and colleagues, in a survey of 1,831 engineers and architects, found that people saw architectural decisions as the most important source of that debt, and that existing tools did not help them manage it in detail (Ernst et al., 2015).
Design flaws carry defect risk beyond size
It is fair to ask whether "smelly" classes are simply large classes. Khomh, Di Penta, Guéhéneuc and Antoniol detected 13 antipatterns across 54 releases of four Java systems. In almost all releases, classes involved in antipatterns were more change-prone and fault-prone than other classes, and class size alone could not explain the difference (Khomh et al., 2012).
Readability points in the same direction. Buse and Weimer trained a model on judgements from 120 annotators that was 80% effective at predicting them. Across more than 2.2 million lines of code, the score correlated with changes and defect indicators. Blank lines mattered more to local readability judgements than comments did (Buse and Weimer, 2010).
Most of what code review finds is about evolvability
Mäntylä and Lassenius classified 388 defects from nine industrial reviews and 371 from 23 student reviews. 75% of the defects found in review did not affect visible functionality. They concerned evolvability: how easy the code is to understand and modify (Mäntylä and Lassenius, 2009). Beller, Bacchelli, Zaidman and Juergens later classified more than 1,400 review-induced changes in two open-source projects and found a similar 75:25 split between maintainability-related and functional changes (Beller et al., 2014).
If your review culture only counts "real bugs" as useful comments, you are discounting most of what reviewers actually catch. McIntosh, Kamei, Adams and Hassan found that review coverage and participation were significantly linked to quality on the Qt, VTK and ITK projects. Components with low coverage and low participation were estimated to have up to two and five additional post-release defects, respectively (McIntosh et al., 2014). A later study added reviewer expertise as a further factor (McIntosh et al., 2016). Understanding the code and the change is the hard part of review (Bacchelli and Bird, 2013).
Refactoring helps, but only when it is targeted
"We should just refactor" is not a plan. In studies at Microsoft, developers saw refactoring as costly and risky, and used the word more loosely than the formal "behaviour-preserving" definition. In Windows 7, the top 5% of preferentially refactored modules saw larger reductions in inter-module dependencies and in several complexity measures than the remaining 95%, but those modules also grew more in size (Kim, Zimmermann and Nagappan, 2012, 2014).
Bavota and colleagues mined and validated 12,922 refactoring operations across three Java systems. Quality metrics usually did not predict where refactoring happened. About 42% of refactorings touched classes that already had code smells, but only 7% actually removed the smell (Bavota et al., 2015). Untargeted cleanup can leave the most harmful structures in place.
What this looks like in a Spring Boot service
The review includes a short illustration, not a measured experiment. Imagine an order endpoint where one controller validates the request, computes discounts with inline conditionals, calls a payment gateway, and writes to the database. That class tends to pick up god-class and long-method smells, high cyclomatic complexity, and a design that is hard to unit-test.
A clearer shape keeps HTTP in the controller, puts the business flow in a service, and hides discount policy and payment behind interfaces. Constructor injection makes every dependency replaceable in a test:
@RestController @RequestMapping("/orders") class OrderController { private final PlaceOrderService placeOrder; OrderController(PlaceOrderService placeOrder) { this.placeOrder = placeOrder; } @PostMapping ResponseEntity<OrderResponse> place(@Valid @RequestBody PlaceOrderRequest req) { Order order = placeOrder.handle(req.toCommand()); // HTTP concerns only return ResponseEntity.status(HttpStatus.CREATED).body(OrderResponse.from(order)); } } // Volatile decisions hidden behind interfaces (information hiding) interface DiscountPolicy { Money discountFor(Customer c, Money subtotal); } interface PaymentGateway { PaymentResult charge(Money amount, PaymentMethod m); } @Service class PlaceOrderService { private final OrderRepository orders; private final DiscountPolicy discounts; private final PaymentGateway payments; PlaceOrderService(OrderRepository o, DiscountPolicy d, PaymentGateway p) { this.orders = o; this.discounts = d; this.payments = p; } @Transactional Order handle(PlaceOrderCommand cmd) { Money subtotal = cmd.subtotal(); Money total = subtotal.minus(discounts.discountFor(cmd.customer(), subtotal)); PaymentResult result = payments.charge(total, cmd.paymentMethod()); if (!result.succeeded()) throw new PaymentDeclinedException(result.reason()); return orders.save(Order.placed(cmd, total, result.reference())); } } // Unit test without Spring context or network: testability by construction @Test void declinedPaymentDoesNotPersistOrder() { var repo = mock(OrderRepository.class); PaymentGateway declining = (amt, m) -> PaymentResult.declined("no funds"); var service = new PlaceOrderService(repo, (c, s) -> Money.ZERO, declining); assertThrows(PaymentDeclinedException.class, () -> service.handle(sampleCommand())); verifyNoInteractions(repo); } A change to discount rules or a payment provider now stays in one implementation. The business flow reads as a short sequence of named steps, and the failure path can be verified without a network or a Spring context. I have not measured this snippet; it is here to connect the reviewed principles to everyday Spring Boot code.
A practical checklist
These are my translation of the evidence for a backend team, not findings of the studies themselves.
- Talk about maintainability in business terms. Report defects, lead time and predictability rather than abstract scores. Track unplanned rework as a rough proxy for the "interest" Besker et al. reported.
- Encapsulate volatile decisions. Put persistence, external API clients, and pricing or policy rules behind interfaces the domain owns. Keep Spring controllers thin.
- Use metrics as pointers, not targets. Complexity scores help locate risky code when a poor rating can be traced to a cause. Combine them with change frequency and defect history, and start with the hotspots.
- Refactor with intent. Tie the work to concrete smells in frequently changed code, protect it with tests, and look at dependencies, complexity and size. Drive-by cleanup rarely removes the smell.
- Review for understandability. Most review findings are evolvability issues. Keep changes small, make sure they are actually reviewed, and route them to people with relevant expertise.
- Treat readability as a quality attribute. Simple layout choices measurably affect how readable code feels. Enforce formatting automatically, so review attention can go to design.
Closing
The lesson I take from this research is to treat maintainability as a continuously managed investment, not an aesthetic preference: make it visible in business terms, protect it with review and tests, and repay it where change is most frequent.
This post is drawn from a narrative literature review I wrote under my name, Maintainable Code as a Driver of Software Quality, Longevity and Team Productivity. It synthesises 23 published sources and does not report new data. A public PDF is not available yet. The review notes that it was prepared with AI-assisted research and writing support, that every cited work was checked against publisher or registry metadata, and that I am responsible for the content and interpretation.
References
- M. M. Lehman, Programs, life cycles, and laws of software evolution, Proc. IEEE, 1980.
- ISO/IEC 25010:2023, Product Quality Model.
- W. Cunningham, The WyCash portfolio management system, OOPSLA '92.
- P. Kruchten, R. L. Nord, and I. Ozkaya, Technical debt: From metaphor to theory and practice, IEEE Software, 2012.
- D. L. Parnas, On the criteria to be used in decomposing systems into modules, Commun. ACM, 1972.
- F. Khomh, M. Di Penta, Y.-G. Guéhéneuc, and G. Antoniol, An exploratory study of the impact of antipatterns on class change- and fault-proneness, Empirical Software Engineering, 2012.
- N. A. Ernst, S. Bellomo, I. Ozkaya, R. L. Nord, and I. Gorton, Measure it? Manage it? Ignore it? Software practitioners and technical debt, ESEC/FSE, 2015.
- T. Besker, A. Martini, and J. Bosch, Technical debt cripples software developer productivity, TechDebt, 2018.
- A. Tornhill and M. Borg, Code Red: The business impact of code quality, TechDebt, 2022.
- R. P. L. Buse and W. R. Weimer, Learning a metric for code readability, IEEE Trans. Softw. Eng., 2010.
- M. Kim, T. Zimmermann, and N. Nagappan, A field study of refactoring challenges and benefits, FSE, 2012; and the 2014 IEEE TSE journal study.
- G. Bavota, A. De Lucia, M. Di Penta, R. Oliveto, and F. Palomba, An experimental investigation on the innate relationship between quality and refactoring, J. Systems and Software, 2015.
- M. V. Mäntylä and C. Lassenius, What types of defects are really discovered in code reviews?, IEEE Trans. Softw. Eng., 2009.
- M. Beller, A. Bacchelli, A. Zaidman, and E. Juergens, Modern code reviews in open-source projects: Which problems do they fix?, MSR, 2014.
- A. Bacchelli and C. Bird, Expectations, outcomes, and challenges of modern code review, ICSE, 2013.
- S. McIntosh, Y. Kamei, B. Adams, and A. E. Hassan, The impact of code review coverage and code review participation on software quality, MSR, 2014; and the 2016 journal study.
The original post is on my blog. More posts at mimi146.github.io/blog.