Code Complexity Is Killing Us
A high level of software complexity can make it difficult to determine architectural hotspots where risk and cost emanate.
Join the DZone community and get the full member experience.Join For Free
While you’re reading this article, if you come across words—and even sentences—that you don’t understand, there’s a high chance you feel like you do when you’re looking at lines of code with a high level of nested complexity. A high level of software complexity can make it difficult to determine architectural hotspots where risk and cost emanate.
Also known as the “arrow anti-pattern,” nested complexity is the use of multiple kinds of control statements (IF, WHILE, FOREACH, SWITCH, etc.) within code. The more nested complexity you have, the less understandable the code will be, leading to a greater probability of software risk and regression.
Code Complexity: A Real-Life Problem
- The code is very complex
- You’re not the one who wrote this code
- People who coded that script left the organization years ago
- The code is not well-documented and method or function names are not very explicit
- The application is still in active development and requires code changes on a regular basis
Code complexity dramatically increases unpredictable maintenance efforts, costs, and delay, all while exposing the organization to a possible loss of stability. Nested complexity can impact long-term quality characteristics of software, such as changeability, transferability, and robustness. It’s not uncommon to come across business applications that suffer from this kind of ailment: hard to move, unable to evolve, prematurely old and retired.
Looking at Appmarq statistics on the rule “Avoid Artifacts with High Depth of Code” illuminates interesting insights on how developers comply with this programming practice.
This rule has been run on more than 1,100 applications that implement a wide variety of technologies: JEE, COBOL, C/C++ and C#, SAP/ABAP and some database-related programming languages such as PL/SQL, Microsoft and Sybase T-SQL, DB2. In the retail example referenced below, the code depth parameter used is 5, meaning a violation is triggered each time a code artifact reaches a level of 5 nested condition statements.
Globally, Appmarq reveals that most software components comply with this quality rule since the overall compliance ratio is at 98.37%. This is a pretty good score compared to other good software programming practices. In a total of 28 million possible cases, only 467,000 objects were found to be defective. However, this complexity phenomenon tends to impact most applications. For example, the average application today includes about 419 defects.
Retail Organizations Distribute More Complex Applications
According to Appmarq, development teams in the retail industry seem to deliver applications with higher nested complexity. With an average of 396 defects by application, this vertical only complies with 96.74%, while other industries score better with an overall compliance ratio above 98%. Conversely, Media (99.54%), Utilities (99.30%), Government (99.05%) and Energy (98.87%) record the highest ratios.
Published at DZone with permission of Michael Muller. See the original article here.
Opinions expressed by DZone contributors are their own.