RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Java Design Patterns: Proven Solutions to Common Problems

Design patterns not only provide proven solutions to common development issues, they also make communication between developers and designers more efficient.


Design patterns have two major benefits. First, they provide proven solutions to common development issues. Each solution facilitates the development of highly cohesive modules with minimal coupling. Design patterns make the overall system easier to understand and maintain. Second, they make communication between developers and designers more efficient.

In general, patterns have four essential elements.

The pattern name is a handle developers can use to describe -- in a word or two -- a design problem, its consequences and its solutions. Naming a pattern immediately increases developers' design vocabulary, allowing them to design at a higher level of abstraction. Having a vocabulary for patterns also makes it easier to think about designs and to communicate them and their trade-offs to others. However, finding good names is one of the hardest parts of developing the design pattern catalog.

The problem defines the design problem and its context, and describes when to apply the pattern to it. It might describe specific design problems such as how to represent algorithms as objects. It might describe class or object structures that are symptomatic of an inflexible design. Sometimes the problem will include a list of conditions that must be met before it makes sense to apply the pattern.

The solution defines the elements that make up the design: their relationships, responsibilities, and collaborations. The solution doesn't describe a particular concrete design or implementation, because a pattern is like a template that can be applied in many different situations. Instead, the pattern provides an abstract description of a design problem and how a general arrangement of elements (classes and objects in this case) solves it.

The consequences are the results and trade-offs of applying the pattern. Though consequences are often unvoiced when developers describe design decisions, they are critical for evaluating design alternatives and for understanding the costs and benefits of applying the pattern. The consequences for software often concern space and time trade-offs. They may address language and implementation issues as well. Because reuse is often a factor in object-oriented design, the consequences of a pattern include its impact on a system's flexibility, extensibility, or portability. Listing these consequences explicitly helps you understand and evaluate them.

Table 1 lists the names and descriptions of a general design pattern template.

Name Description
Pattern name and classification A conceptual handle and category for the pattern
Intent What problem does the pattern address?
Also known as Other common names for the pattern
Motivation A scenario that illustrates the problem
Applicability In what situation can the pattern be used?
Structure Diagram using the Object Modeling Technique (OMT)
Participants Class and objects in design
Collaborations How classes and objects in the design collaborate
Consequences What objectives does the pattern achieve? What are the tradeoffs?
Implementation Implementation details to consider, language-specific issues
Sample code Sample code in Java and C++
Known uses Examples from the real world
Related patterns Comparison and discussion of related patterns
Table 1. General Design Pattern Template Name and Description

Table 2 lists the names and descriptions of a Java-specific design pattern template.

Name Description
Pattern name The name and a reference to where it was first described
Synopsis A very short description of the pattern
Context A description of the problem the pattern is intended to solve
Forces A description of the considerations that led to the solution
Solution A description of the general solution
Consequences Implications of using the pattern
Implementation Implementation details to consider
Java API usage An example from the Java APO (when available)
Code example A code example in the Java language
Related patterns A list of related patterns
Table 2. Java Design Pattern Template Name and Description

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date