Book Review: "Java by Comparison"

Posted by Steven

Recently, I finished reading “Java by Comparison – Become a Java Craftsman in 70 Examples” by Simon Harrer, Jörg Lenhard and Linus Dietz. This article is a book review that highlights the contents of the book as well as some aspects that I found especially good.

Before I get into the contents, a little disclaimer. I was asked to write a book review by one of the authors who send me the book for free. However, this doesn’t stop me to be perfectly honest in what I write here.

As the title suggests, the book is structured in more than 70 short chapters that each highlight one aspect of good programming or language feature. Always on the left side, a code block shows a certain situation. Below, a textual explanation about the good and not-so-good aspects of this code is explained in detail. The right side of each chapter shows an upgraded and better version of the code and again some textual context. This structure makes understanding the examples and the changes made on the code base very intuitive. Also, every chapter has a comprehensive code example that the reader can copy in his IDE and experiment with.

The beginning of the book covers very fundamental topics like why to avoid negations and structuring code with empty space. As a seasoned software craftsman, it’s easy to disregard those as too basic. However, I encountered exactly those anti-patterns / bugs in production code written by juniors. If they had read “Java by Comparison”, their code would have looked much better.

Mid-book topics like exception handling and testing are covered in detail. These are two topics I’ve seen done wrong in code written by developers with some years of experience. Hence, I’m quite glad to see them being discussed in the book. Also, basic concepts of Java 8 are included which is a must-have for every Java-teaching medium these days.

The last part of the book made me especially happy because not only issues from “the real” software development like automated builds and logging are briefly described. Also, the authors emphasized the need to continue learning to become a good software craftsman and to use the community in this effort. As a community organizer and speaker, I cannot stress enough how important an active developer community is.

Also very much to my liking, the authors chose to use space-related business logic for their examples. Yeay!


The book is great for young Java developers that are at the beginning of their careers. If they already know the basics but want to learn how to write good code as well as some more advanced topics of the language, “Java by Comparison” is the right book.