1 Managing code quality

 

This chapter covers

  • Various techniques to improve the quality of your code
  • Advantages and disadvantages of static analysis
  • Approaches to make static analysis more useful
  • Testing and assertions

Every software developer introduces bugs to the code—there’s no way to avoid them completely. Some bugs cause very subtle changes to a program’s behavior no user would reasonably care about. However, other bugs are much more severe and, depending on the project, could lead to millions of dollars in loss, a destroyed spacecraft, or even the loss of human lives. Most bugs fall somewhere in the middle: they don’t have disastrous effects, but they annoy users and require hours of debugging and fixing.

Some bugs are caused by a misunderstanding of the specification requirements, a miscommunication between the software development team and the customer, or a similar human error. Other bugs are created by a miscommunication between the developer and the machine. That is, the developer correctly understands the problem but writes the wrong code, so the machine solves the problem incorrectly. This book is devoted to this second category.

1.1 Code review and pair programming

1.2 Code style

1.3 Static analysis

1.3.1 Static analysis tools for Java

1.3.2 Using static analyzers

1.3.3 Limitations of static analysis

1.3.4 Suppressing unwanted warnings

1.4 Automated testing

1.5 Mutation coverage

1.6 Dynamic analysis

1.7 Code assertions

Summary