chapter one

1 Managing code quality

 

This chapter covers

  • The purpose and the structure of this book
  • Various techniques to improve the code quality
  • 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 of the bugs cause very subtle change in program behavior and nobody cares about it. Other bugs may cost millions of dollars, lost spacecraft, or even human lives. Many of them are 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 misunderstanding of the specification requirements, miscommunication between the software development team and the customer, and so on. Another category of bugs comes from the 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 the latter category.

1.1 The structure of this book

1.2 Code review and pair programming

1.3 Code style

1.4 Static analysis

1.4.1 Static analysis tools for Java

1.4.2 Using static analyzers

1.4.3 Limitations of static analysis

1.4.4 Suppressing unwanted warnings

1.5 Annotation packages

1.6 Automated testing

1.7 Mutation coverage

1.8 Dynamic analysis

1.9 Code assertions

1.10 Summary