Watch our latest Product Showcase

Group 370

Meet us at WeAreDevelopers World Congress in Berlin

Group 370

Spotlight Whitepaper by IDC on Importance of Automated Code Review Technologies

Group 370

The Economics of Code Quality

In this article:
Subscribe to our blog:

Poor code quality costs money.

This may sound obvious when explicitly stated, but how often this gets forgotten is incredible. Part of this is just the nature of producing code. When developers are deep into their integrated development environment (IDE), they aren’t thinking about the company's operational costs. They are thinking about getting stuff done.

But part of it is because it is rarely stated explicitly how much poor code quality can cost a company. Here, we want to take you through some of these costs to model a scenario where code quality is a lesser priority and how that can affect a company’s bottom line.

The Key Costs of Poor Quality Code

The impact of poor code quality on a business can be significant. A study from Stripe back in 2018 put the potential costs of bad quality code at $85 billion. A more recent study looking at not just time lost for developers but also costs associated with security issues in poor code, put this number at an eye-watering $2.41 trillion.

Now, whether poor-quality code costs more than Italy's GDP isn’t really the point. Rather, the point is that poor quality code really does have a monetary impact on both companies and the economy as a whole, often in ways that are not immediately apparent. Here's a breakdown of the key areas where costs can mount:

Development Costs

High-quality code is efficient, clean, and easy to work with. When code quality is compromised, the opposite is true. Developers spend excessive time debugging and performing rework, which should have been unnecessary with better code standards. This slows down the development process and increases the cost significantly.

Poor quality code may require frequent revisits to fix bugs that weren't apparent initially or to redo sections of code that don't perform as expected. These additional hours spent on fixing and reworking directly inflate the development costs.

Maintenance Costs

Once code is deployed, the maintenance phase begins. This is where poor-quality code can become a recurring expense. Code that is not well-written often requires more frequent updates and fixes.

These maintenance activities are not just about correcting errors; they often involve optimizing the code to meet changing requirements or improving performance issues not addressed during development. The time and resources spent on these activities are a direct consequence of the initial code quality, and this ongoing maintenance becomes a continuous drain on resources.

Operational Costs

The quality of code directly impacts the performance and reliability of software systems. Poor code can lead to increased system downtime, inefficiencies in operations, and various performance issues.

These problems can escalate operational costs in many ways, such as needing additional hardware resources to compensate for inefficient code, increased support and troubleshooting efforts, and lost productivity due to system unavailability or failures.

Staff Turnover

The frustration stemming from dealing with poorly written code can significantly impact developer morale. Constantly grappling with a difficult codebase to understand, maintain, and improve can be demotivating and stressful for developers.

This dissatisfaction can lead to a higher turnover rate as developers seek more fulfilling and less frustrating work environments. The cost of replacing skilled developers is not trivial. It includes not just the financial aspect of hiring and training new staff but also the loss of institutional knowledge and the time it takes for new staff to reach full productivity.

Customer Satisfaction

Finally, the end-users of the software are often the first to experience the consequences of poor code quality. Bugs, crashes, and slow performance directly impact the user experience, leading to customer dissatisfaction. In today's market, where alternatives are often readily available, this dissatisfaction can quickly result in customer churn.

Losing customers not only impacts revenue but also increases the cost of acquiring new customers to replace those that are lost. The reputation damage from poor user experiences can have long-term effects on a company's brand and its ability to attract new customers.

In summary, the costs associated with poor code quality are diverse and substantial. They affect not just the immediate financials of development and maintenance but also have far-reaching consequences on operational efficiency, employee satisfaction, and customer loyalty. Recognizing and addressing these costs is crucial for any organization that relies on software for its operations and growth.



Modeling Out the Costs of Poor Quality

Let's create a simplified model to estimate the economic impact of poor code quality. We'll start with basic assumptions and ballpark figures:

  • Average Developer Hourly Rate: $50
  • Average Number of Developers: 10
  • Working Hours per Day: 8 hours
  • Number of Working Days in a Month: 20 days

With that, we can start to estimate the additional costs due to poor code quality. First, increased development time. We’ll assume poor code quality increases development time by 20%.

  • 20% of 8 hours = 1.6 extra hours per developer per day.

Then we’ll add in increased maintenance time. This is significantly impacted by poor code quality, so let’s say maintenance efforts are 30% higher due to poor code quality.

  • 30% of 8 hours = 2.4 extra hours per developer per day.

We’ll add staff turnover, with a 10% higher turnover rate due to poor code quality.

  • Cost to Replace One Developer: $10,000 (recruitment, training, etc.)

With those figures in place, we can calculate the monthly economic impact of poor code. First, we can the increased development cost. We’ve estimated that each developer needs 1.6 hours per day extra because of poor quality code.

We have ten developers on the team, which is 16 developer hours per day, equating to an added daily cost of $800 (16 hours * $50 average developer hourly rate). This makes the monthly increased development cost = $800 * 20 days = $16,000.

We calculate the cost for increased maintenance similarly (2.4 hours * 10 developers * $50 * 20 days), adding a monthly cost of $24,000.

For the added staff turnover cost, we’ll assume that normally, one developer leaves every six months. With a 10% increase, this becomes approximately 2 developers every 6 months. Additional turnover cost per month = ($10,000 * 1 additional developer) / 6 months = $1,666.67

So, the total increased cost due to poor code quality:

  • Development: $16,000
  • Maintenance: $24,000
  • Turnover: $1,666.67
  • Total: $41,666.67

Poor code quality would cost this organization an additional $41,666.67 per month.

Adding in the Costs of Churn

Incorporating customer churn into the model adds another dimension to understanding the economic impact of poor code quality. Let's make some assumptions and add this factor to our existing model.

Let’s assume our MRR is $100, and our current customer base is 1,000 customers. A Normal Monthly Churn Rate might be 2%, and increased churn due to poor code quality is an additional 1%, bringing total churn to 3%.

That additional churn is 10 customers per month, meaning additional revenue loss per month = 10 customers * $100 = $1,000.

This brings the total estimated monthly economic impact of poor code quality to $42,666.67. This model highlights the direct costs associated with development and maintenance and the indirect impact on revenue through customer loss.

It's crucial to consider both direct and indirect costs when assessing the economic impact of code quality. The customer loss might seem small compared to the direct costs, but this number can only worsen as code quality declines.

Poor code leads to poor product, and lower customer satisfaction, leading to even more churn. This also doesn’t accommodate the increased costs associated with the increase in customer support the team will have to provide due to the poor quality of the product.

Additionally, these customers leave bad reviews or spread bad word-of-mouth, leading to lower acquisition as well as lower retention.

Reversing the decline by improving code quality

The positive here is that these numbers aren’t set. Any improvements in code quality are going to start reducing costs. The improvements might be:

  1. Adopting coding standards and best practices. Establishing and adhering to coding standards and best practices is crucial. This includes consistent naming conventions, code structure, and adherence to established patterns in software design. Such standards make the code more readable, maintainable, and less prone to errors.
  2. Regular code reviews. Implementing a process for regular peer code reviews can significantly enhance code quality. These reviews allow for the early detection and rectification of issues before the code is merged into the main codebase. It also promotes knowledge sharing and collaboration among team members.
  3. Automated testing. Automated tests, including unit, integration, and system tests, can prevent many quality issues from reaching production. Automating these tests ensures they run consistently and frequently, catching issues early in the development cycle.
  4. Refactoring and code debt management. Regular refactoring of technical debt–the process of restructuring existing code without changing its external behavior–is vital. It helps reduce code complexity and make the codebase easier to understand and maintain. Managing technical debt actively is also crucial to prevent the accumulation of issues over time.
  5. Training and skill development. Investing in training and skill development for developers ensures they are up-to-date with the latest coding techniques, technologies, and best practices. This investment can improve the overall quality of the code they produce.
  6. Leveraging code quality tools. Utilizing tools like Codacy Quality that analyze code quality can provide valuable insights. These tools can automatically detect potential issues like code smells, security vulnerabilities, and performance bottlenecks.
  7. Fostering a quality-focused culture. Cultivating a quality-oriented culture that values quality over speed is essential. Encouraging developers to take the time needed to produce high-quality code can be more beneficial than rushing to meet unrealistic deadlines in the long run.

By implementing these improvements, organizations can reduce the immediate and long-term costs associated with poor code quality and enhance their product's reliability, performance, and user satisfaction. This proactive approach to improving code quality invests in the organization's future success and sustainability.

Let's model a scenario where code quality improves by 20%. With a 20% improvement, the development time increase reduces to 16% (1.28 extra hours per day), and the maintenance time increase reduces to 24% (1.92 extra hours per day). Staff turnover decreases to 8%, and additional churn decreases to 0.8%.

Here’s how all of that works out:

  1. Development Cost Reduction: 
    • New estimate: 1.28 hours * 10 developers * $50 * 20 days = $12,800
    • Reduction: $16,000 (original) - $12,800 = $3,200
  2. Maintenance Cost Reduction:
    • New estimate = 1.92 hours * 10 developers * $50 * 20 days = $19,200
    • Reduction: $24,000 (original) - $19,200 = $4,800
  3. Staff Turnover Cost Reduction:
    • New turnover cost per month = ($10,000 * 0.8 additional developers) / 6 months = $1,333.33
    • Reduction: $1,666.67 (original) - $1,333.33 = $333.34
  4. Customer Churn Cost Reduction:
    • New additional churn = 0.8% of 1,000 * $100 = $800
    • Reduction: $1,000 (original) - $800 = $200

So, the total savings with 20% quality improvement are $8,533.34, with a new monthly economic impact of the poor quality of the code $34,133.33.

This illustrates the significant economic benefits of investing in code quality, not only in direct costs but also in reducing staff turnover and customer churn.



An Uncomfortable Truth

These are the kind of ballpark models you should be running in your head whenever you encounter code quality issues in your codebase. If you see something that will cost your team hours to fix, consider how that time relates to dollars, euros, or pounds.

But the bad news about all this is that these costs will always be there. No codebase, no developer, nor no team is perfect. You are incurring these costs right now. The aim is to understand the true cost of poor code quality and constantly look for ways to reduce and mitigate these costs—better standards, reviews, tools, and training.

All these can help you reduce these costs while building a better product for customers with a happier team.

Codacy can help your team improve code quality across the board by standardizing and automating the code review process.

Our platform quickly scans your code repositories, checking them against thousands of quality and security rules. Codacy also allows you to analyze robust code quality and health reports for all your repositories on a single, easy-to-understand dashboard.

To see how it works, sign up for a free trial today


New project quality settings to improve Codacy code check
With the new ability to define project quality settings, we help you perform better code quality checks using Codacy automated code review tool. The...
7 Metrics for Measuring Code Quality
Remember the days of buggy apps? The crashes, the confusion, the updates that felt like downgrades? Those were the days of "ship it as long as it...
Improve code quality: from people to organizations
We have exciting news to share with you to improve code quality.

Automate code
reviews on your commits and pull request

Group 13