Quality is an elusive goal. Ask a thousand coding managers to describe quality and there's a strong chance you'll receive approximately the same number of definitions.
"When I think about good quality code, three characteristics come to mind: readability, consistency, and modularity," says Lawrence Bruhmuller, vice president of engineering at Superconductive, which offers an open-source tool for data testing, documentation, and profiling.
Bruhmuller believes that code should be easily accessible by all parties. "That means clear naming of variables and methods and appropriate use of whitespace," he explains. Code should also be easy enough to follow with only minimal explanatory comments. "A codebase should be consistent in how it uses patterns, libraries, and tools," Bruhmuller adds. "As I go from one section to the other, it should look and feel similar, even if it was written by many people."
There are several techniques project leaders can use to evaluate code quality. A relatively easy way is scanning code for unnecessary complexity, such as inserting too many IF statements in a single function, Bruhmuller notes. Leaders can also judge quality by the number of code changes needed to fix bugs, revealed either during testing or by users. "However, it's also important to trust the judgment of your engineers," he says. "They are a great judge of quality."
The major difference between good- and poor-quality coding is maintainability, states Kulbir Raina, Agile and DevOps leader at enterprise advisory firm Capgemini. Therefore, the best direct measurement indicator is operational expense (OPEX). "The lower the OPEX, the better the code," he says. Other variables that can be used to differentiate code quality are scalability, readability, reusability, extensibility, refactorability, and simplicity.
"Code quality can also be effectively measured by identifying technical-debt (non-functional requirements) and defects (how well the code aligns to the laid specifications and functional requirements," Raina says. "Software documentation and continuous testing provide other ways to continuously measure and improve the quality of code using faster feedback loops," he adds.