Design Pattern Ideas

Idea Type Categories Patterns
parameterize a system by the classes of objects it creates Creational Subclassing - Object Composition Factory Method - Abstract Factory, Builder, Prototype
provide a level of indirection Structural Before the fact - After the fact - Properties - Stand-in Bridge - Adapter - Decorator - Proxy
recursive composition to organize an open-ended number of objects Structural Treatment - Responsibility Composite - Decorator
Encapsulating Variation Behavioral Algorithm - State-dependent behavior - Protocol - Traversal Strategy - State - Mediator - Iterator
Objects as Arguments Behavioral Polymorphic operation - Request - State Visitor - Command - Memento
Communication Behavioral Encapsulated - Distributed Mediator - Observer
Decoupling Senders and Receivers Behavioral Binding - Signaling - Indirect reference - Percolating Command - Observer - Mediator - Chain of responsibility
Finding Appropriate Objects Abstracting Reality Treat objects uniformly - Interchangeable families of algorithms - State of an entity as an object Composite - Strategy - State
Determining Object Granularity Abstracting Reality Represent complete subsystem as object - Support huge numbers of objects at the finest granularities - Creating other objects - Implement a request on another object or group of objects Facade - Flyweight - Abstract Factory, Builder - Visitor, Command
Specifying Object Interfaces Abstracting Reality Encapsulate internal state of an object - Identical interfaces - Reflect classes Memento - Decorator, Proxy - Visitor
Class vs. Interface (subclass vs. subtype) Specifying Object Implementations Subclass - Subtype - Abstract class Composite - Chain of Responsibility - Command, Observer, State, Strategy
Delegation (of a request) Specifying Object Implementations To an object that represents state - To an object that represents algorithm - To an object that traverses structure State - Strategy - Visitor
Avoiding change-induced problems Designing for Change Problem:
  1. Creating an object by specifying a class explicitly
  2. Dependence on specific operations
  3. Dependence on hardware and software platform
  4. Dependence on object representations or implementations
  5. Algorithmic dependencies
  6. Tight coupling
  7. Extending functionality by subclassing
  8. Inability to alter classes conveniently
  1. Abstract Factory, Factory Method, Prototype
  2. Chain of Responsibility, Command
  3. Abstract Factory, Bridge
  4. Abstract Factory, Bridge, Memento, Proxy
  5. Builder, Iterator, Strategy, Template Method, Visitor
  6. Abstract Factory, Bridge, Chain of Responsibility, Command, Facade, Mediator, Observer
  7. Bridge, Chain of Responsibility, Composite, Decorator, Observer, Strategy
  8. Adapter, Decorator, Visitor

Some "Definitions"

Type
Interface
Dynamic Binding
Polymorphism

Design Patterns in MVC

Design Pattern "Space"

  Purpose
Creational Structural Behavioral
Scope Class Factory Method Adapter Interpreter
Template Method
Object Abstract Factory
Builder
Prototype
Singleton
Adapter
Bridge
Composite
Decorator
Facade
Proxy
Chain of Responsibility
Command
Iterator
Mediator
Memento
Flyweight
Observer
State
Strategy
Visitor

Design aspects that design patterns let you vary

Purpose Design Pattern Aspect(s) That Can Vary
Creational Abstract Factory families of product objects
Builder how a composite object gets created
Factory Method subclass of object that is instantiated
Prototype class of object that is instantiated
Singleton the sole instance of a class
Structural Adapter interface to an object
Bridge implementation of an object
Composite structure and composition of an object
Decorator responsibilities of an object without subclassing
Facade interface to a subsystem
Flyweight storage costs of objects
Proxy how an object is accessed; its location
Behavioral Chain of Responsibility object that can fulfill a request
Command when and how a request is fulfilled
Interpreter grammar and interpretation of a language
Iterator how an aggregate's elements are accessed, traversed
Mediator how and which objects interact with each other
Memento what private information is stored outside an object, and when
Observer number of objects that depend on another object; how the dependent objects stay up to date
State states of an object
Strategy an algorithm
Template Method steps of an algorithm
Visitor operations that can be applied to object(s) without changing their class(es)

The Delegate "Pattern"

Favor object composition over class inheritance

This can be seen as Acquaintance (compile-time) vs. Aggregation (run-time). Patterns which can help with Aggregation: Composite, Decorator, Chain of Responsibility, Observer

Program to an interface, not an implementation. Creational patterns let you abstract the process of object creation; you can associate an interface with its implementation transparently at instantiation.