The full title reads “Java by Comparison - Become a Java Craftsman in 70 Examples”.
When I first heard of the book I was sceptical: Is there really enough common ground for 70 good code examples? Would the examples be the starting point of an argument if you would show them to a team of programmers? After a conference in Berlin, Simon offered me a free copy to read.
TL;DR: Reading the book delight replaced my scepticism.
The first two chapters cover the grounds of code structuring and formatting to avoid errors and difficult to understand code. The chapter about comments outlines what comments to remove, and what comments and JavaDoc to write. This chapter and the chapter on exception handling will prove helpful when discussing these topics in a development team.
The chapter on Java streams gives you a short overview how to use this new Java 8 feature. It also contains neat examples when to use and when not to use Java’s Optional.
In some of the chapters, there are short elaborations where there are multiple opinions, for example on the use of early and multiple return statements in a method. The authors use these elaborations appropriately and keep them to the point. Each chapter contains references to external resources for further reading.
There is a short chapter with examples around tests with JUnit. For further insights the authors point the reader to “Pragmatic Unit Testing in Java 8 with JUnit”, another book in the Pragmatic Programmers series.
Reading the book, I missed the topics of time and date handling and locale - two topics that in my experience are often a source of mischief.
The final chapter gives an outlook to the real world. The first section very briefly touches static analysis tools you can use in your build. While these tools are famously known for their false positives, they can be of great benefit if they are properly configured. Once you’ve read the 70 examples and the best practices, you should use the static analysis tools to apply the best practices consistently and automatically. Use them to raise the bar for the bugs - but not to annoy the programmers.
I recommend this book to programmers that are familiar with the Java Language in general and want to learn about best practices. It might also prove helpful if you want to refresh your memory or read about a different point of view after you’ve worked a few years in the industry.