Java Coding Guidelines

Author: Fred Long, Dhruv Mohindra, Robert C. Seacord , Dean F. Sutherland, David Svoboda
Publisher:  Addison-Wesley
ISBN: 978-0321933157
Print: 032193315X
Audience: Java Programmers
Rating: 5
Reviewer: Alex Armstrong

Not another book of dos and don'ts?!

No it's is much more than a book of dos and don'ts. If you read one book on Java this year make it this one. It is enjoyable, informative and you will be a better programmer for it, or at least you will believe you are.

What makes this book different is that it isn't just a list of rules that you read and commit to memory it is a set of 75 recommendations that tell you the basic idea, show you how not to do it and then show you the correct way. If the book has a flaw then its that there are only 75 recommendations - if you read the book it will almost certainly leave you wanting more. 


There are five chapters each dealing with a different aspect of coding in Java. It starts off with Chapter 1 Security and this is something of a shame because not every programmer is interested in security and many of the guidelines are very specific - prevent LDAP injection, prevent code injection and so on. It is interesting, and it is important given how we tend to ignore security or regard it as an afterthought, but it isn't quite as interesting as the following chapters.

Chapter 2 Defensive Programming is more general and has a wider application. Advice like minimize the scope of variables is something that you need to keep in mind no matter what you are programming. Some of these are old and reasonably well known but the presentation is still worth reading.




Chapter 3 Reliability comes next and here we have a matter of opinion - what exactly does enhance reliability? Some of the suggestions could be moved into defensive programing or the next chapter on making programs more understandable. In the main they are reasonable and you aren't going to argue with do not shadow or obscure identifiers in sub-scopes but not so sure about do not declare more than on variable per declaration. 

The material in Chapter 4 Program Understandability.really should be drummed into every programmer when first learning any language. After all, you don't write programs for computers you write them for other programmers. Again we have a mix of well known generalities and some very specific guidelines - be careful using visually misleading identifiers and do not place a semicolon immediately following an if, for or while condition. 

The final section Chapter 5 Programmer Misconceptions is perhaps the most interesting of all. Who could resist the possibility that they have been misled, perhaps for years and years. Again some are fairly obvious - understand the differences between bitwise and logical operators - others less so - do not attempt to help the garbage collector by setting local references - I won't do that again. 



It doesn't matter if you have encountered the advice that this book offers; it is the fact that it shows you an example or two of how not to follow the advice that makes it better than the average guidelines book.

Overall it is a good read as long as your Java is good, but not too good otherwise you probably know everything the book has to tell you. Recommended as a pleasant and worthwhile read when you have a few moments to spare.



To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.


Modern Frontend Development with Node.js

Author: Florian Rappl
Publisher: Packt Publishing
Date: November 2022
Pages: 208
ISBN: 978-1804618295
Print: 1804618292
Kindle: B0B9BH5WBS
Audience: Node.js developers
Level: Introductory/Intermediate
Rating: 3
Reviewer: Ian Elliot
Modern development - what else is there?

Go Programming Language For Dummies

Author: Wei-Meng Lee
Publisher: For Dummies
Date: April 2021
Pages: 336
ISBN: 978-1119786191
Print: 1119786193
Kindle: B0921HHN48
Audience: People wanting to learn Go
Rating: 4
Reviewer: Mike James
Can a dummy master Go?

More Reviews


Last Updated ( Friday, 27 January 2017 )