Design Patterns in Java

I've recently started writing a series of articles on Design Patterns in Java, i.e., Design Patterns explained using Java source code examples. Although it will take me a little while to create each design pattern example, this page will eventually contain links to all of those examples.

If you're not familiar with software design patterns, they're described on Wikipedia like this:

In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code.

The usefulness of design patterns is explained well by this quote:

Design patterns can speed up the development process by providing tested, proven development paradigms.

As we all like to program faster -- and we don't like to paint ourselves into corners -- design patterns are a good thing. I've found that design patterns are like being able to talk with an experienced software designer ... a way of capturing "lessons learned" about good software design practices.

Back to top

Design patterns - history, organization

Design patterns were initially made famous in the "the "Gang of Four" Design Patterns book , and subsequently described in other books, such as The Design Patterns Smalltalk Companion. "Patterns" themselves originated in the field of architecture, as captured and organized by a man named Christopher Alexander (no relation to this author).

Design patterns have been split into at least three categories -- Creational Patterns, Structural Patterns, and Behavioral Patterns -- and in keeping with this organization, my tutorials are organized in the same manner below.

Back to top

Design patterns in Java

While design patterns are intended to be independent of programming languages, I've found that it's very useful to show examples of design patterns implemented in different languages. For example, if you're not familiar with Smalltalk, the Design Patterns Smalltalk Companion may be a little hard for you to digest, but if you're familiar with a language like Java, a Java design pattern example will be much easier to understand.

Therefore, to specifically try to help Java programmers, I'm creating this series of Java design pattern examples.

Back to top

Java 'Creational' design pattern examples

According to Wikipedia, "creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation." Here are links to my Java Behavioral Design Pattern examples:

Back to top

Java 'Structural' design pattern examples

According to Wikipedia, "structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities." Here are links to my Java Behavioral Design Pattern examples:

  • Adapter Design Pattern
  • Bridge Design Pattern
  • Composite Design Pattern
  • Decorator Design Pattern
  • Facade Design Pattern
  • Flyweight Design Pattern
  • Private Class Data
  • Proxy Design Pattern
Back to top

Java 'Behavioral' design pattern examples

According to Wikipedia, "behavioral design patterns are design patterns that identify common communication patterns between objects and realize these patterns. By doing so, these patterns increase flexibility in carrying out this communication." Here are links to my Java Behavioral Design Pattern examples:

Back to top

While some other "patterns" or "idioms" aren't always considered to be "design patterns", they are nonetheless very helpful. Therefore, I'm including links here to other patterns and idioms that I've written over the years, including The Law of Demeter, and the Model View Controller pattern:

Back to top

Java design patterns - Summary

I hope these Java design patterns are helpful. If possible, I'll add more over time.

Back to top

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.