The Strategy design pattern embodies two fundamental tenets of object-oriented (OO) design: encapsulate the concept that varies and program to an interface, not an implementation. In this article, David Geary shows how to use the Strategy pattern to implement an extensible design. (2,000 words; April 26, 2002)
The Command pattern lets an application framework make requests of application-specific objects, without the framework knowing the objects' exact type or the application-specific behavior they implement. In his latest Java Design Patterns column, David Geary explores how to use the Command pattern both in client-side Java to attach application-specific behavior to Swing menu items and in server-side Java to implement application-specific behavior with the Apache Struts application framework. (2,700 words; June 28, 2002)
The Chain of Responsibility (CoR) pattern decouples the sender and receiver of a request by interposing a chain of objects between them. In this installment of Java Design Patterns, David Geary discusses the CoR pattern and two implementations of that pattern in the Java APIs-one from client-side Java and the other from server-side Java. (2,200 words; August 29, 2003
The Decorator design pattern lets you attach responsibilities to objects at runtime. This pattern proves more flexible than inheritance, which is static. In this latest installment of Java Design Patterns, David Geary explores Decorator with an implementation example. (2,800 words; December 14, 2001)
Examples of the Iterator and Observer pattern can be found in most object-oriented systems and class libraries. Using these two patterns together to create Iterator Observers can help reduce code duplication and promote the degree to which software components depend on each other (coupling). The looser the coupling between components or subsystems the easy they are to interchange and maintain. (2,000 words)
JavaSoft has tightened up the specification for loading and unloading classes in the upcoming Java 1.2 release. The changes to the specification and the JDK 1.2 implementation allow Java programmers to (finally) safely take advantage of the traditional implementation of the Singleton pattern. (750 words)
The Observer pattern lets you build extensible software with pluggable objects by allowing communication between loosely coupled objects. In his latest Java Design Patterns column, David Geary explores the Observer pattern, how it's used throughout the Java 2 SDK, and how you can implement the pattern in your own code. (1,800 words; March 28, 2003)
The Facade design pattern simplifies complex APIs by providing a simplified interface to a complex subsystem. In this installment of Java Design Patterns, David Geary explores a built-in Swing facade for creating dialog boxes and a custom facade for getting a Swing application off the ground. (1,500 words; May 30, 2003)
The Visitor pattern is often used to separate the structure of an object collection from the operations performed on that collection. For example, it can separate the parsing logic in a compiler from the code generation logic. By keeping those separate, you can easily use different code generators. Even better, other utilities such as lint can use the parsing logic without dragging along the code generation logic. Unfortunately, adding new object types to a collection often requires modifying the visitor classes that have already been written. This article presents a more flexible approach to implementing visitors in Java, using reflection. (1,600 words)
15. How to decouple the Observer/Observable object model
By using a decoupling technique, you can optimize the performance of the Observable by isolating, or decoupling, it from the dissemination of information to the Observers. (1,150 words)
16. Learn how to implement the Command pattern in Java
Sometimes it's necessary to issue requests to objects without knowing anything about the operation being requested or the receiver of the request. In procedural languages, this type of communication is accomplished via a callback: a function that is registered somewhere to be called at a later point. Commands are the object-oriented equivalent of callbacks and encapsulate the callback function. This Java Tip demonstrates how to implement the Command pattern in Java. (1,070 words)