Getting Started with Google Guava

Getting Started with Google Guava

At the time of writing this there is basically no literature regarding this awesome library from Google. For those of you who have never heard of Google Guava – it is a collection of Google’s core Java libraries that they use in their Java projects. This short but very informative book was written by Bill Bejeck, senior software engineer with 10 years of experience. For more information check out his blog. I would also like to give credit to my friend Petr Fiala who was kind enough to help me with this review and consulted me on some of the less known topics to me. I would also like to thank Packt Publishing for giving me access to this book.

When it comes to book itself, its, as I mentioned earlier, quite a short book. With only 142 pages this book is really easy to read in a relatively short amount of time. Author takes us on a journey through the most useful concepts and constructs in Guava in only nine chapters. This is really good news! Author expects the reader to know basic Java so he does not waste printing paper/disk space and most of all – your time, by explaining some basic Java concepts. When it comes to explaining its always to the point.

Style of writing is easily understandable and author always provides explanations to back his opinions. Guava classes are explained in pretty straight forward manner – pure Java example followed by Guava example with appropriate explanation. This way reader can directly see benefits from the use of Guava such as reduced amount of code, most of the time cleaner code (with exception of constructs also present in Java 7 – there is not that much of a difference, but if you were forced to use older releases of Java, you would surely appreciate provided Guava solutions) and improved readability of code.

There are many mentions throughout the book about functionality from Guava that has been included in Java 7 release. I like this very much because it gives the reader the opportunity to decide whether to use Guava or upgrade to Java 7 and use native JDK tools. It also shows that the author keeps up with current news in Java world. By the looks of new Java 8, some of the features are strongly inspired by Guava constructs, as it happened with for example Java 7 and automatic resource management (= try-with-resources construct).

What I find especially useful about this book is the fact that it advocates the use of Guava with dependency injection frameworks like Spring or Guice. Written material as well as attached sources make use of Spring for demonstration purposes. Most of provided code comes with JUnit unit tests. This is quite a rare feature since most introductory books with similar structure and goals are usually described without any regard to these kind of frameworks so I find this to be a big plus.

Another good practice mentioned throughout this book is the use of so called fluent programming. Approach heavily used in Guava library to leverage all its power. If you have never heard of this, it is an approach that allows us developers to chain method calls together, making for a more readable code. Apart from this, author describes the use of functional programming which provides really elegant way of solving problems that would otherwise require a lot of boilerplate code. These two concepts combined with Guava’s collections give programmers really powerful set of tools for solving everyday problems encountered in Java software development.

Where it excels

When it comes to solving everyday problems this book provides great insights on creating clean and readable code that solves these problems using Guava. It also advocates many of the best practices used in the field these days so there is a good chance that reader will pick up on these and start to use them on their own. What is really nice about this book is the fact that many chapters directly impact other chapters (based on design of Guava library) and it shows the way to orchestrate your code to leverage the most from Guava (mainly first 4 chapters). Libraries like Guava usually do not live by themselves and this book is aware of this fact and provides examples that are set in dependency injection framework (Spring). There is a set of unit tests for each chapter that provides the means to check the functionality of explained code.

Where it comes short

I have nothing to criticize when it comes to the content of the book. Every chapter provides plenty of useful examples and suitable explanation and covers most important concepts from given area of Guava. The only aspect that was not entirely perfected was the formatting  side of the book. Some code snippets could use better formatting and also fonts used in the book are not quite uniform. There were some issues with code samples presented in the book (like code that will not compile due to the use of multiple double quotes, doubled annotations and other). I submitted all encountered issues and based on the word from publisher these issues will be reviewed by editorial team so we might get updated version soon.


After reading this book I felt satisfied and also enlightened in a way. Some of the concepts explained by the book were entirely new to me and some chapters deepened my knowledge in their respected areas. When it comes to deciding whether to read this book or not I would recommend reading it. It has something for everyone and while reading it you will find yourself thinking I had to do this at one point and you will be presented with one possible way of solving given problem in quite an elegant way. To conclude this review – definitely worth reading.

Leave a Reply

Your email address will not be published. Required fields are marked *