TechBookReport logo



Keywords: Java, code quality, programming

Title: Java By Comparison

Author: Simon Harrer, Jörg Lenhard, Linus Dietz

Publisher: Pragmatic Bookshelf

ISBN: 978-1680502879

Media: Book

Verdict: Recommmended for those beginning Java programmers who want to improve their code

 

While there is no shortage of books introducing programming or a specific programming language, there seem to be far fewer books to help programmers get to the next step once they've mastered the basics. This book is aimed at readers in that wide expanse between beginner and expert and is explicitly designed to answer that simple question: how can I improve my coding skills further? In this case the coding is in Java, but many of the examples, tips and techniques are actually language independent and would apply to any programming language. Of course if you're a beginner in another language it means there's an extra layer of work to do, but for Java beginners this is an ideal starting point for improving your code.

The format of the book is straightforward. The authors provide a series of examples of coding practice, showing a before and after. The before is always a piece of correct code that can be improved. These before examples are not designed to show errors as such, they are designed to show examples of code that is hard to read, understand or maintain. This is syntactically and algorithmically working code of the type that a competent beginner might produce. The authors then explain what the problem is, picking out the elements of the example that make it problematic.

The after code, on the facing page, shows how it can be improved. Often it's a matter of a few tweaks. The key changes are highlighted and there's a written explanation of why it was changed in the way that it was. Having the two code snippets side by side makes for a very clean style — a bit like the style that the authors display in their refactored examples.

Spread across nine chapters, these examples range from the merely stylistic as regards formatting, use of space, naming conventions and so on to looking at the use of the Java API, the design of objects, the use of lambdas to end with real-world build and analysis tools. It's a broad sweep that starts gently and becomes steadily more sophisticated. One benefit of this approach is that there is something for every level of Java developer, from the absolute beginner to those who've already got some years under their belt.

Overall this is a very readable and useful book. The examples are well chosen and there's no doubt that coders who adopt the rules and techniques here will be writing better code. It's not simply a list of stylistic rules that will help, though a reminder of some basics can never go amiss, it's that the book is imbued with an outlook that encourages good practice. Recommended.


Hit the 'back' key in your browser to return to subject index page

Return to home page

Contents © TechBookReport 2019. Published January 22 2019