Title: Design patterns in Java
Authors: Metsker, S. J. and Wake, W. C.
This book is a modern version of the famous gang-of-four book (Design Patterns: Elements of Reusable Object-Oriented Software by Gamma et al.), enhanced with usage and implementation examples for Java. After a short introduction into design patterns, it explains 20 design patterns. The patterns are grouped into chapters that make some sense, e.g., chapter Interface Patterns contains descriptions of the Adapter, Facade, Composite and Bridge patterns, and the Construction chapter contains the Builder, Factory Method, Abstract Factory, Prototype and Memento patterns. The book gives examples on how to use the pattern using a simple software system for an business that manufactures fireworks. It does not develop a whole example application though, its just isolated code snippets with a common theme. It contains quite a bit of example code and UML diagrams. It contains challenges for the reader, mostly suggestions on how to extend the example code, and the results are given at the end of the book.
… and opinion
The book is clearly written, the ordering mostly makes sense and the coding examples are quite good for making you understand the pattern. Understanding the patterns in one thing, applying them into your code is another though. I think it would be cool if the authors had given more additional real-world examples where the patterns are used in real code, e.g., in stuff like Swing or other famous Java libraries the reader may know. Applying these patterns takes practice, but this book gives you the background needed to practice. I had not read any book on design patterns before (only articles on the internet and stuff like this), and I was happy with it. If you have already read another book on design patterns or know them, you will most likely not need this book for the Java-specific examples.
My personal take-home from the book
- A design pattern is an established way of doing something, to achieve something.
- Design patterns help to make your code more simple and thus easier to change/maintain.
- I want to make use of design patterns in my code, and try to refactor some ugly code I need to maintain to use these patterns.