Design Patterns Cheat Sheet

While studying design patterns with the help of an exceptional learning aid called Head First Design Patterns, I made a list of the programming design patterns they cover. This information below works as a cheat sheet for me. Feel free to print this page and use it as a study tool. That's what I did.

Creational Patterns

Abstract Factory Pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes. 

Factory Method Pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

Builder Pattern separates the construction of a complex object from its representation so that the same construction process can create different representations. 

Prototype Pattern specifies the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype. 

Singleton Pattern ensures a class has only one instance, and provides a global point of access to it.

Structural Patterns

Adapter Pattern converts the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn't work otherwise because of incompatible interfaces.

Bridge Pattern decouples an abstraction from its implementation so that the two can vary independently.

Composite Pattern allows you to compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

Decorator Pattern attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to sub classing for extending functionality.

Facade Pattern provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

Flyweight Pattern uses sharing to support large numbers of fine-grained objects efficiently.

Proxy Pattern provides a surrogate or placeholder for another object to control access to it.

Behavioral Patterns

Chain of Responsibility Pattern avoids coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.

Command Pattern encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.

Interpreter Pattern: Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.

Iterator Pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying implementation. 

Mediator Pattern defines an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.

Memento Pattern: Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.

Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.

State Pattern allows an object to alter its behavior when its internal state changes. The object will appear to change its class.

Strategy Pattern defines a family of algorithms, encapsulates each one and makes them interchangeable. Strategy lets the algorithms vary independently from the clients that use it.

Template Method Pattern defines the skeleton of an algorithm in a method, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.

Visitor Pattern represents an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.

Published Sunday, July 20, 2008 8:05 PM by Tod Birdsall
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Tod Birdsall said:

Added the Singleton Pattern.

November 19, 2008 3:39 PM
 

Tod Birdsall said:

Added the Command Pattern

December 11, 2008 3:25 PM
 

Don Spaulding said:

I too have a design patterns cheat sheet, here:

http://docs.python.org/reference/index.html

It's amazing how little code you can write when the language itself is designed with great patterns in mind.  :-D

Seriously though, regardless of the language, knowing how to effectively use these design patterns can make for happier code(rs).

February 6, 2009 9:59 AM
 

Tod Birdsall said:

Knowing how to effectively use the patterns seems to be the trick. I would like to do a series of posts on using these patterns in the wild, specifically for C# and .NET.

February 14, 2009 7:31 PM

Leave a Comment

(required) 
(optional)
(required) 
Submit
Picture of Tod Birdsall

Welcome!

This is the personal website of Tod Birdsall, a programmer, business analyst, and gamer. Not necessarily in that order. Learn more...

Subscribe

Be notified of my latest posts. Subscribe to my blog.