Design Patterns Reconsidered
The Design Patterns book launched a revolution in object-oriented design and provided a vocabulary for OO developers to communicate their ideas. However, in some cases, patterns used blindly can lead to awkward, confusing, or hard to maintain code. It is time for some common patterns used in Java to be reconsidered so that we can derive the benefits from patterns while minimizing their concerns.
This talk will re-evaluate key patterns like Singleton, Template Method, Visitor, and Proxy. These patterns have downsides and in some cases, do more harm than good. Examples of each pattern will be give in Java and examined for clarity, testability, and flexibility. Important problems will be discussed and examples of alternate solutions will be given.
In the Singleton pattern, we'll look at problems like hidden coupling, testability, and extensibility and examine ways to use interfaces and dependency injection to avoid the need for the classic Singleton pattern. We'll also re-examine the double checked locking idiom and update it with current advice.
In the Template Method pattern will look at problems with communicating intent, composition, and API evolution and examine ways to refactor your code to use composition instead by way of interfaces, factories, and strategies.
In the Visitor pattern we'll look at how changes in data structures break existing visitors, problems with intermingling navigation and behavior, return values, exception handling, performance, and more. We'll look at alternative implementations that alleviate some of these problems.
In the Proxy pattern, we'll look at problems with maintaining proxies in the face of interface changes, loss of identity and type precision, and coupling. We'll examine some alternatives like static and dynamic code generation and composition.
About Alex Miller
Alex Miller is a Sr. Engineer with Terracotta Inc, the makers of the open-source Java clustering product Terracotta. Prior to Terracotta, Alex worked at BEA Systems on the AquaLogic product line and was Chief Architect at MetaMatrix. His interests include Java, concurrency, distributed systems, query languages, and software design. Alex enjoys writing his blog at http://tech.puredanger.com and has spoken at a number of Java user group meetings and conferences.
In St. Louis, Alex is responsible for founding the Lambda Lounge, a user group for the study of functional and dynamic languages.
More About Alex »