Dev Notes – Design Patterns


Creational

  • Abstract Factory
  • Builder
  • Factory Method (Virtual Constructor)
  • Prototype
  • Singleton

Structural

  • Adapter (Wrapper)
  • Decorator
  • Proxy
  • Façade
  • Flyweight
  • Bridge
  • Composite

Behavioural

  • Mediator
  • Strategy (Policy)
  • Template Method
  • Chain of Responsibility
  • Command
  • Memento
  • Interpreter
  • Iterator
  • Observer
  • State

 

Creational

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

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

Factory Method
Virtual Constructor. Methods which create an instance of another class.

Prototype
Cloning an object by reducing the cost of creation.

Singleton
Ensure a class allows only one object to be created, providing a single point of access to it.

Structural

Adapter (Wrapper)
Convert the interface of a class into another interface clients expect.

Decorator
Allows behaviour to be added to an existing object dynamically.

Proxy
Provide a surrogate or place-holder for another object to control access to it.

Façade
Change the way a difficult interface works by presenting a more simpler interface, easier to work with.

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

Bridge
HAS-A. Decouple an abstraction from its implementation so that each may vary independently.

Composite
Compose objects into tree structures. Treat branches and leafs the same.

Behavioural

Mediator
Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.

Strategy (Policy)
Classes whose functionality doesn’t agree with the extended class functionality.

Template Method
Define the skeleton of an algorithm in a method, deferring some steps to sub-classes.

Chain of Responsibility
Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request.

Command
Allows us to de-couple an object making a request from the object that receives the request and performs the action, by means of a “middle-man” object.

Memento
Used to store the state of an object to return it that state later. E.g Undo.

Interpreter
Used for definition of a representation for given language grammar along with an interpreter that uses the representation to interpret sentences in the language.

Iterator
Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

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

State
Allow an object to alter its behaviour when it’s internal sate changes. The object will appear to change its class.

Visitor
Lets you define a new operation without changing the classes of the elements on which it operates. Double dispatch.


Published by:  mike    April 27th, 2013    Java  

Leave a Reply

Your email address will not be published. Required fields are marked *