Author: Ian F. Darwin
Audience: Java practitioners
Reviewer: Alex Armstrong
Does Java need a traditional cookbook anymore?
This is a fairly straightforward cookbook in the traditional sense of the word - it has lots of recipes for getting fairly small jobs done. It has already made it to a third edition, growing by 50 pages and including Java 8. It has 24 chapters and covers a lot of ground, but as always with a cookbook, how useful you find it to be depends on how much it fits in with what you want to do.
What is certain is that this is not textbook or an introduction to Java in cookbook format. It does start off with some basic topics. Chapter 1 is about getting started with Java, downloading, using Ant, Maven, Gradle and so on. This sounds sensible, but the coverage is so slight that it really only amounts to "these things exist - go and find out about them".
In fact this is a problem with the whole book - it covers so much ground that even in 800+ pages it doesn't really do any of its topics justice.
Things are a bit better once the book gets started on recipes that lend themselves to code. Chapters 2 and 3 deal with Strings and regular expressions respectively. Don't expect to learn anything from scratch, but you stand a chance of learning how to do some practical things assuming you already know about Strings and regular expressions. For example, the introduction to regular expressions more-or-less just tells you to look at a table of syntax and then follows up with some examples. This is also where you start to notice the references to code on the book's website - a welcome extra, but not so good if you just want to read a book.
Next we have two chapters on numbers and date and time (new in Java 8). Then a chapter on general data structures, arrays, collections and so on. This more or less ends the coverage of basic data manipulation techniques.
From here we start moving out from the core of the language. Chapter 8 puts the object-oriented view and Chapter 9 the functional. Neither chapter is about the deep theory or philosophy of the approaches, but about the mechanics of getting things done. The object-oriented chapter has recipes on inner classes, how to define callbacks and so on. The functional chapter is mostly about the new lambda functions included in Java 8.
The next few chapters are broadly about formatted data handling - file I/O, directory operations and working with media files. Chapter 13 deals with networking at the sockets level. Then we have a fairly long chapter on the subject of working with a GUI - mostly about Swing.
After a chapter on localization, the book goes off into server and database topics - server side Java, email, database access (JDBC), JSON and XML. Often the coverage is on the short side.
The book comes to a close with some chapters on what you might call advanced Java - packages, threading, reflection and finally using Java with other languages.
This is a big cookbook but it often suffers from not enough space to do the topics it covers justice. In addition there is a tendency for the recipe to say "How to do X" and the solution then says "Use the X class or class library that the author implemented". You might think that this isn't a valid cookbook recipe because it goes beyond just using what is supplied in Java, but then if you want to do X it might be exactly what you need.
With these reservations this is a good book of its type. It is well written and the author includes small asides and comments which lighten the load of reading so much code. If you prefer looking things up online then don't bother with this book, but if you like the traditional cookbook approach and don't want to wade though multiple incorrect and irrelevant answers before you find one that might be right, then this is worth a try.
To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for new additions to Book Watch and the latest reviews.