Are you a junior or regular developer (especially working in Java), who would like to write high quality code – more readable, understandable and efficient? Or maybe you are a consultant, a senior developer, a teacher. And you noticed that the beginner programmers often make the same mistakes?
I have a good news for you – a book that might interest you. It’s „Java by Comparison. Become a Java Craftsman in 70 Examples”, written by Simon Harrer, Jörg Lenhard and Linus Dietz. Published “by professional developers for professional developers”.
Even if you are not familiar with Java and you are using usually other object-oriented programming languages (like C#), this book is still worth your attention. Due to the strong similarities and reference to many paradigms and principles applicable to object-oriented programming.
I think that it would be useful for every person mentioned above:
- as a guide with valuable tips for developers who want to improve their skills,
- from the teacher’s level: as a reading for students and a reference point for indicating programming mistakes
How is this book organized?
It contains a description of 70 examples of the most common mistakes along with comparisons of the source code “before” and “after“. Showing how to avoid bad practice by doing it differently.
The authors are experienced developers who decided to collect these errors into a form of a book – to save time both for themselves and for students. When they saw the same mistakes made by their students again and again…
There are only two hard things in Computer Science: cache invalidation and naming things.Phil Karlton
It is worth drawing attention to fact, that each case is well-named, so each person can easily refer to the name of a given problem during discussion.
What’s more, in the examples themselves there are references to other named problems to better illustrate how they differ or how they are similar to each other.
This helps not only students, but also teachers who do not have to explain the same problems each time. They only indicate their names in the book so that the student can study them.
Boring cases? – not there
An interesting fact is that the examples are mostly presented in the context of a trip to Mars. For example the code shows the delivery process of supplies to the space shuttle.
It’s nice to read that form instead of boring, repeated hundreds of times in the scientific community texts such as “we have square class that inherits from a rectangle“.
What’s behind these cases exactly?
The topics are mainly about:
- code readability (which allows faster understanding of the code by other programmers)
- simplification of complex conditions and methods
- avoiding errors related to the “Null” values
- good practices in designing objects (e.g. immutability)
- so-called “code symmetry” – for example in the creation of method signatures
- writing reasonable comments and documentation (JavaDoc)
- naming conventions in Java
- business context and domain terminology
- advice for using “exceptions” properly
- writing unit tests in a good way
- tips & tricks for using functional programming in cooperation with imperative approach
- avoiding side effects of computing operations
- preparation for a real production environment, including static code analysis tools, continuous integration, logging, etc.
“Java by Comparison” is a good supplement to other popular books about clean code, because it shows the above-mentioned things in a slightly different way. It also affects topics related to the multithreaded code (tips on how to minimize and isolate it).
What I liked personally after reading this book is that it contains links to other books and articles for people who want to deepen their knowledge on the topic even more. These are, in my opinion, good reference points for further development and really worth reading (especially “classic” books).
I was positively surprised by the content of this book and I definitely recommend it – a must-read for every Java programmer.
Where to get it?
- publishing house: https://pragprog.com/book/javacomp/java-by-comparison
- Amazon store: https://www.amazon.com/Java-Comparison-Become-Craftsman-Examples/dp/1680502875
You can see more details there (e.g. customer reviews). The position has its own website: https://java.by-comparison.com/