Chapter 9. Code Quality


Few would deny the importance of writing quality code. High quality code contains less bugs, and is easier to understand and easier to maintain. However, the precise definitions of code quality can be more subjective, varying between organizations, teams, and even individuals within a team.

This is where coding standards come into play. Coding standards are rules, sometimes relatively arbitrary, that define the coding styles and conventions that are considered acceptable within a team or organization. In many cases, agreeing on a set of standards, and applying them, is more important than the standards themselves. Indeed, one of the most important aspects of quality code is that it is easy to read and to understand. If developers within a team all apply the same coding standards and practices, the code will be more readable, at least for members of that team. And if the standards are commonly used within the industry, the code will also be more readable for new developers arriving on the team.

Coding standards include both aesthetic aspects such as code layout and formatting, naming conventions, and so forth, as well as potentially bad practices such as missing curly brackets after a condition in Java. A consistent coding style lowers maintenance costs, makes code clearer and more readable, and makes it easier to work on code written by other team members.

Only an experienced developer can really judge code quality in all its aspects. That is the ...

Get Jenkins: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.