Code quality is a way to talk about how efficient, readable, and usable code is. Coding is inherently open-ended, and you can solve the same problem in the same programming language in multiple ways. Code quality measures the accuracy and reliability of code—but being bug-free and portable is not the only measure of code quality. It also includes how developer-friendly the code is. Code quality also describes how easy it is to understand, modify, and reuse the code if necessary.","sortDate":"2023-10-11","headlineUrl":"https://aws.amazon.com/what-is/code-quality/?trk=faq_card","id":"faq-hub#what-is-code-quality","category":"Developer Tools","primaryCTA":"https://portal.aws.amazon.com/gp/aws/developer/registration/index.html?pg=what_is_header","headline":"What is Code Quality? "},"metadata":{"tags":[{"id":"GLOBAL#tech-category#devtools","name":"Developer Tools","namespaceId":"GLOBAL#tech-category","description":"Developer Tools","metadata":{}},{"id":"faq-hub#faq-type#what-is","name":"what-is","namespaceId":"faq-hub#faq-type","description":"
what-is","metadata":{}}]}}]},"metadata":{"auth":{},"testAttributes":{}},"context":{"page":{"locale":null,"site":null,"pageUrl":"https://aws.amazon.com/what-is/code-quality/","targetName":null,"pageSlotId":null,"organizationId":null,"availableLocales":null},"environment":{"stage":"prod","region":"us-east-1"},"sdkVersion":"1.0.115"},"refMap":{"manifest.js":"289765ed09","what-is-header.js":"251923df8a","what-is-header.rtl.css":"ccf4035484","what-is-header.css":"ce47058367","what-is-header.css.js":"004a4704e8","what-is-header.rtl.css.js":"f687973e4f"},"settings":{"templateMappings":{"category":"category","headline":"headline","primaryCTA":"primaryCTA","primaryCTAText":"primaryCTAText","primaryBreadcrumbText":"primaryBreadcrumbText","primaryBreadcrumbURL":"primaryBreadcrumbURL"}}}
Code quality is a way to talk about how efficient, readable, and usable code is. Coding is inherently open-ended, and you can solve the same problem in the same programming language in multiple ways. Code quality measures the accuracy and reliability of code—but being bug-free and portable is not the only measure of code quality. It also includes how developer-friendly the code is. Code quality also describes how easy it is to understand, modify, and reuse the code if necessary.","id":"seo-faq-pairs#what-is-code-quality","customSort":"1"},"metadata":{"tags":[{"id":"seo-faq-pairs#faq-collections#code-quality","name":"code-quality","namespaceId":"seo-faq-pairs#faq-collections","description":"
code-quality","metadata":{}}]}},{"fields":{"faqQuestion":"Why is code quality important?","faqAnswer":"
You can write a software function using several hundred lines of code or just a few dozen lines. Your approach could depend on a number of things. For example, you'd consider your programming paradigm. You can also factor in your design patterns, your problem-solving approach, capabilities of your programming language, and your use of external libraries. \n
Code quality represents the efficiency of the code, not just in its functionality but also in its readability and long-term management. \n
Quality code makes everyone’s job easier by saving time and resources. Here's a brief rundown of who and how it helps: \n
- \n
- Quality code helps a developer reread, build on, and refactor their own code \n
- It helps other developers understand and collaborate on someone else’s code \n
- It helps the system architect or project lead check for adherence to structure and coordinate the team’s work efforts \n
- It helps other stakeholders in software development—such as security or operations teams—test, deploy, and secure the code \n \n
Experience over time helps developers refine their coding techniques and approaches to produce high-quality code. ","id":"seo-faq-pairs#why-is-code-quality-important","customSort":"2"},"metadata":{"tags":[{"id":"seo-faq-pairs#faq-collections#code-quality","name":"code-quality","namespaceId":"seo-faq-pairs#faq-collections","description":"
code-quality","metadata":{}}]}},{"fields":{"faqQuestion":"How do you measure code quality?","faqAnswer":"
Quantitative code quality metrics are discrete and measurable. One example could be the number of errors caught in the code of a software application that has been running for 1,000 hours. \n
Qualitative code quality metrics are subjective and descriptive. For example, an expert developer can check over a junior developer’s work and make comments. \n
By combining quantitative and qualitative assessments, it’s possible to attain the best measure of software quality. Other factors that make up code quality include documentation, efficiency, end-user usability, timeliness, and security. \n
Next, we explain the six key code quality areas of measurement. \n
Reliable \n
Reliable code runs as documented each and every time you run it. Reliable code is also robust; it handles unexpected inputs and interruptions without crashing or other rogue behaviors. \n
To measure reliability, include tracking metrics like the number of system failures over a given time period, mean-time-to-failure, and number of known bugs. \n
Extendible \n
A piece of software may run perfectly every time, but what if the code needs to be changed a bit? Or what if it needs to be used in building out new functionality? What if the developer who originally wrote the code is no longer available? \n
If code is extendible, it's easy the code to update or modify after it's complete and correct in the initial specifications. Here are factors relevant to extendible code: \n
- \n
- Overall software architecture \n
- Modularity \n
- Compliance with coding standards \n
- Length, size, and complexity of the code base \n \n
There are various tools, such as static analysis and dependency mapping, that can score these metrics after they read the code base. \n
Testable \n
A piece of code should be easy to develop tests for and run tests on. \n
For instance, it is challenging to write tests that cover every scenario if a single function contains multiple logic steps or references other parts of the software. In contrast, breaking down software into logically separate units, or modules, makes it easier to test. \n
To measure testability, you can use these techniques: \n
- \n
- Map tests to written requirements \n
- Use tools that examine test-to-code coverage \n
- Implement cyclomatic complexity tools like Halstead complexity measures to assess code complexity \n \n
Developers may also follow test-driven development paradigms and perform regular manual code reviews to improve testability. \n
Portable \n
You might want it to be easy to take the code from one environment the make it work again in another environment. If so, you can measure portability. \n
For example, if you wanted to take an Android app and port it to iOS, how much work would be involved? If you produce code with cross-platform use cases in mind, porting to a new target system becomes relatively easy. \n
Portability is dependent on how tightly coupled the code is to its underlying software and hardware target system. Tightly coupled code requires highly specific virtual machines to run. \n
In contrast, code deployed in containers can run in any environment. In some cases, complete code refactoring may be necessary to uncouple the functionality from the target system. \n
Reusable \n
High-quality code is modular and designed for reuse. For instance, a function designed to add tasks to a task-tracking database could be reused in different parts of a software project, or in a different software project altogether. \n
Software components designed for reuse are often attached to APIs. APIs provide a standard way to interface with the functionality of the reusable code, rather than simply copying and pasting a function.","id":"seo-faq-pairs#how-do-you-measure-code-quality","customSort":"3"},"metadata":{"tags":[{"id":"seo-faq-pairs#faq-collections#code-quality","name":"code-quality","namespaceId":"seo-faq-pairs#faq-collections","description":"
code-quality","metadata":{}}]}},{"fields":{"faqQuestion":"What are some tips to improve code quality?","faqAnswer":"
There are many different types of tools that help check and improve code quality. For example, you can use testing frameworks and tools for many purposes: \n
- \n
- Static code analysis \n
- Software versioning \n
- Coding style checks \n
- Code complexity and cyclomatic complexity checks \n
- Comprehensive test coverage \n
- Performance testing \n
- Security verification \n \n
By incorporating one or more tools into the software development lifecycle, it becomes easier to build high-quality code with every project. Make sure to integrate tools into the integrated development environment (IDE) so developers can build high-quality software projects from the start. \n
You can also build in automated code quality checks and code review tools trigged during continuous integration and development (CI/CD) events, like pushing code to a Git repository. \n
Next are some more strategies to improve code quality. \n
Read about IDEs » \n
Reviews \n
Automation and specialty software tooling help to review code quality, but there are benefits in manual code reviews as well. \n
Pair programming activities involve getting developers to check each other’s code to catch quality issues missed in solo programming. You can review based on guidance from programming paradigms and design patterns like object-oriented programming, functional programming, and model-view-controller pattern. \n
Refactoring \n
After code quality testing and code review have identified lower-quality code in a codebase, you may flag the code for refactoring. \n
Refactoring rebuilds the same code to be of higher quality or more performant. The code must be tested thoroughly before and after refactoring to ensure that no bugs are introduced in the development process. \n
Documentation \n
To build high-quality code, you need high-quality requirements documentation. This documentation should consistently and thoroughly outline the functional, nonfunctional, and performance requirements of the system. These documents guide effective, thorough architecture design and testing. \n
Style guides \n
Style guides cover a set of conventions for developing code. These conventions cover style-based aspects like formatting, naming, and indentation. While code may still run when it isn’t built to these conventions, it decreases the quality in terms of maintainability. \n
When they follow style guides, such as Python’s PEP 8, developers can build code that can be read and maintained by other developers. \n
Coding standards \n
Coding standards go beyond the basic stylistic conventions of style guides. They become more like standard operating procedures (SOPs) in how to develop code. They include guidelines on design patterns to use, architectural rules, and how to do error handling. \n
Coding standards may be community-based, such as the SEI CERT C Coding Standard for secure coding. You can also develop them in-house for guidance specific to your organization or projects. \n
Both style guides and coding standards help define code quality long before a project ever starts.","id":"seo-faq-pairs#tips-to-improve-code-quality","customSort":"4"},"metadata":{"tags":[{"id":"seo-faq-pairs#faq-collections#code-quality","name":"code-quality","namespaceId":"seo-faq-pairs#faq-collections","description":"
code-quality","metadata":{}}]}},{"fields":{"faqQuestion":"How can AWS help improve code quality?","faqAnswer":"
Amazon Web Services (AWS) offers many solutions to help developers build quality code and measure code quality: \n
- \n
- Amazon Q Developer helps developers and IT professionals with all of their tasks across the software development lifecycle—from coding, testing, and upgrading, to troubleshooting, performing security scanning and fixes, optimizing AWS resources, and creating data engineering pipelines. \n
- Amazon CodeGuru Security is a static application security testing (SAST) tool that combines machine learning (ML) and automated reasoning. It identifies vulnerabilities in code, provides recommendations on how to fix the vulnerabilities, and tracks the status of the vulnerabilities until closure. \n
- Amazon CodeGuru Profiler helps your developers find an application’s most expensive lines of code. This helps them to understand the runtime behavior of their applications. They can identify and remove code inefficiencies, improve performance, and significantly decrease compute costs. \n
- AWS Cloud9 is a cloud-based IDE that provides the software and tooling you need to develop in dynamic programming languages. These languages include JavaScript, Python, PHP, Ruby, Go, and C++. \n \n
You can also choose from several code quality tools for various purposes in the AWS Marketplace. \n
Get started with building quality code on AWS by creating an account today.","id":"seo-faq-pairs#how-can-aws-improve-code-quality","customSort":"5"},"metadata":{"tags":[{"id":"seo-faq-pairs#faq-collections#code-quality","name":"code-quality","namespaceId":"seo-faq-pairs#faq-collections","description":"
code-quality","metadata":{}}]}}]},"metadata":{"auth":{},"pagination":{"empty":false,"present":true},"testAttributes":{}},"context":{"page":{"locale":null,"site":null,"pageUrl":"https://aws.amazon.com/what-is/code-quality/","targetName":null,"pageSlotId":null,"organizationId":null,"availableLocales":null},"environment":{"stage":"prod","region":"us-east-1"},"sdkVersion":"1.0.115"},"refMap":{"manifest.js":"3dea65b485","rt-faq.rtl.css":"75bc12ff4b","rt-faq.css":"b00bda11a1","rt-faq.css.js":"0af1d62724","rt-faq.js":"da177bdd5f","rt-faq.rtl.css.js":"a89cd83194"},"settings":{"templateMappings":{"question":"faqQuestion","answer":"faqAnswer"}}}
What is code quality?
Code quality is a way to talk about how efficient, readable, and usable code is. Coding is inherently open-ended, and you can solve the same problem in the same programming language in multiple ways. Code quality measures the accuracy and reliability of code—but being bug-free and portable is not the only measure of code quality. It also includes how developer-friendly the code is. Code quality also describes how easy it is to understand, modify, and reuse the code if necessary.
Why is code quality important?
You can write a software function using several hundred lines of code or just a few dozen lines. Your approach could depend on a number of things. For example, you'd consider your programming paradigm. You can also factor in your design patterns, your problem-solving approach, capabilities of your programming language, and your use of external libraries.
Code quality represents the efficiency of the code, not just in its functionality but also in its readability and long-term management.
Quality code makes everyone’s job easier by saving time and resources. Here's a brief rundown of who and how it helps:
- Quality code helps a developer reread, build on, and refactor their own code
- It helps other developers understand and collaborate on someone else’s code
- It helps the system architect or project lead check for adherence to structure and coordinate the team’s work efforts
- It helps other stakeholders in software development—such as security or operations teams—test, deploy, and secure the code
Experience over time helps developers refine their coding techniques and approaches to produce high-quality code.
How do you measure code quality?
Quantitative code quality metrics are discrete and measurable. One example could be the number of errors caught in the code of a software application that has been running for 1,000 hours.
Qualitative code quality metrics are subjective and descriptive. For example, an expert developer can check over a junior developer’s work and make comments.
By combining quantitative and qualitative assessments, it’s possible to attain the best measure of software quality. Other factors that make up code quality include documentation, efficiency, end-user usability, timeliness, and security.
Next, we explain the six key code quality areas of measurement.
Reliable
Reliable code runs as documented each and every time you run it. Reliable code is also robust; it handles unexpected inputs and interruptions without crashing or other rogue behaviors.
To measure reliability, include tracking metrics like the number of system failures over a given time period, mean-time-to-failure, and number of known bugs.
Extendible
A piece of software may run perfectly every time, but what if the code needs to be changed a bit? Or what if it needs to be used in building out new functionality? What if the developer who originally wrote the code is no longer available?
If code is extendible, it's easy the code to update or modify after it's complete and correct in the initial specifications. Here are factors relevant to extendible code:
- Overall software architecture
- Modularity
- Compliance with coding standards
- Length, size, and complexity of the code base
There are various tools, such as static analysis and dependency mapping, that can score these metrics after they read the code base.
Testable
A piece of code should be easy to develop tests for and run tests on.
For instance, it is challenging to write tests that cover every scenario if a single function contains multiple logic steps or references other parts of the software. In contrast, breaking down software into logically separate units, or modules, makes it easier to test.
To measure testability, you can use these techniques:
- Map tests to written requirements
- Use tools that examine test-to-code coverage
- Implement cyclomatic complexity tools like Halstead complexity measures to assess code complexity
Developers may also follow test-driven development paradigms and perform regular manual code reviews to improve testability.
Portable
You might want it to be easy to take the code from one environment the make it work again in another environment. If so, you can measure portability.
For example, if you wanted to take an Android app and port it to iOS, how much work would be involved? If you produce code with cross-platform use cases in mind, porting to a new target system becomes relatively easy.
Portability is dependent on how tightly coupled the code is to its underlying software and hardware target system. Tightly coupled code requires highly specific virtual machines to run.
In contrast, code deployed in containers can run in any environment. In some cases, complete code refactoring may be necessary to uncouple the functionality from the target system.
Reusable
High-quality code is modular and designed for reuse. For instance, a function designed to add tasks to a task-tracking database could be reused in different parts of a software project, or in a different software project altogether.
Software components designed for reuse are often attached to APIs. APIs provide a standard way to interface with the functionality of the reusable code, rather than simply copying and pasting a function.
What are some tips to improve code quality?
There are many different types of tools that help check and improve code quality. For example, you can use testing frameworks and tools for many purposes:
- Static code analysis
- Software versioning
- Coding style checks
- Code complexity and cyclomatic complexity checks
- Comprehensive test coverage
- Performance testing
- Security verification
By incorporating one or more tools into the software development lifecycle, it becomes easier to build high-quality code with every project. Make sure to integrate tools into the integrated development environment (IDE) so developers can build high-quality software projects from the start.
You can also build in automated code quality checks and code review tools trigged during continuous integration and development (CI/CD) events, like pushing code to a Git repository.
Next are some more strategies to improve code quality.
Reviews
Automation and specialty software tooling help to review code quality, but there are benefits in manual code reviews as well.
Pair programming activities involve getting developers to check each other’s code to catch quality issues missed in solo programming. You can review based on guidance from programming paradigms and design patterns like object-oriented programming, functional programming, and model-view-controller pattern.
Refactoring
After code quality testing and code review have identified lower-quality code in a codebase, you may flag the code for refactoring.
Refactoring rebuilds the same code to be of higher quality or more performant. The code must be tested thoroughly before and after refactoring to ensure that no bugs are introduced in the development process.
Documentation
To build high-quality code, you need high-quality requirements documentation. This documentation should consistently and thoroughly outline the functional, nonfunctional, and performance requirements of the system. These documents guide effective, thorough architecture design and testing.
Style guides
Style guides cover a set of conventions for developing code. These conventions cover style-based aspects like formatting, naming, and indentation. While code may still run when it isn’t built to these conventions, it decreases the quality in terms of maintainability.
When they follow style guides, such as Python’s PEP 8, developers can build code that can be read and maintained by other developers.
Coding standards
Coding standards go beyond the basic stylistic conventions of style guides. They become more like standard operating procedures (SOPs) in how to develop code. They include guidelines on design patterns to use, architectural rules, and how to do error handling.
Coding standards may be community-based, such as the SEI CERT C Coding Standard for secure coding. You can also develop them in-house for guidance specific to your organization or projects.
Both style guides and coding standards help define code quality long before a project ever starts.
How can AWS help improve code quality?
Amazon Web Services (AWS) offers many solutions to help developers build quality code and measure code quality:
- Amazon Q Developer helps developers and IT professionals with all of their tasks across the software development lifecycle—from coding, testing, and upgrading, to troubleshooting, performing security scanning and fixes, optimizing AWS resources, and creating data engineering pipelines.
- Amazon CodeGuru Security is a static application security testing (SAST) tool that combines machine learning (ML) and automated reasoning. It identifies vulnerabilities in code, provides recommendations on how to fix the vulnerabilities, and tracks the status of the vulnerabilities until closure.
- Amazon CodeGuru Profiler helps your developers find an application’s most expensive lines of code. This helps them to understand the runtime behavior of their applications. They can identify and remove code inefficiencies, improve performance, and significantly decrease compute costs.
- AWS Cloud9 is a cloud-based IDE that provides the software and tooling you need to develop in dynamic programming languages. These languages include JavaScript, Python, PHP, Ruby, Go, and C++.
You can also choose from several code quality tools for various purposes in the AWS Marketplace.
Get started with building quality code on AWS by creating an account today.
- Amazon CodeGuru Security is a static application security testing (SAST) tool that combines machine learning (ML) and automated reasoning. It identifies vulnerabilities in code, provides recommendations on how to fix the vulnerabilities, and tracks the status of the vulnerabilities until closure. \n
- Amazon Q Developer helps developers and IT professionals with all of their tasks across the software development lifecycle—from coding, testing, and upgrading, to troubleshooting, performing security scanning and fixes, optimizing AWS resources, and creating data engineering pipelines. \n