Design Patterns | Classification

A design pattern is a generic, repeatable solution to a frequent issue in software design. Many software developers over a sizable period of time came up with these solutions through trial and error. They are like pre-made blueprints that can be customized to solve a recurring design problem in the code.

  Characterization (Purpose)
Creational Structural Behavioural
Scope Class Factory Method Adapter(class)
  Bridge (class) Template Method
Object Abstract Factory Adapter(object) Chain Of Responsibility
Builder Bridge (object) Command
Prototype Composite Iterator
Singleton Decorator Mediator
  Glue (Facade) Memeto
  Flyweight Observer
  Proxy State
    Strategy
    Visitor
Compound Builder   Interpreter
  Composite Iterator (compound)
  Wrapper (Decorater) Walker (Visitor)

Jurisdiction/Scope is the domain over which the pattern applies.

  • Patterns with class scope deals with relationship between base classes and their sub-classes.
  • Patterns with object scope concerns  with relationship between peer objects.
  • Patterns with compound scope deals with recursive object structures.

Note: Some patterns capture concepts that span jurisdictions. e.g. Iteration applies to both collection of objects (object jurisdiction) and to recursive object structures(compound jurisdiction). Hence, there are both object and compound version of Iterator pattern.

Characterization/Purpose reflects what the pattern does.

  • Creational patterns concerns with the process of object creation. It deals with initializing and configuring classes and objects.
  • Structural patterns deals with composition of objects or classes. It deals with decoupling interface and implementation of classes & objects.
  • Behavioral patterns characterize the way in which classes or objects interact and distribute responsibilities. It deals with dynamic interaction among societies of classes & objects

Creational patterns

  • Factory Method: Creates an instance of several dereived classes
  • Abstract Factory: Factory for building related object
  • Builder: Separate an object construction from its implementation
  • Prototype: Factory for cloning new instances from a prototype
  • Singleton: A class of which a single object can exist

Structural patterns

  • Adapter: Match interface of different classes
  • Bridge: Separates on Object’s interface from its implementation
  • Composite: A tree structure of simple & composite objects
  • Decorator: A responsibilities of Objects dynamically
  • Facade: A single class that represents the entire subsystem.
  • Flyweight: A find-grained objects shared efficiently
  • Proxy: An object representing another object

Behavioral patterns

  • Chain Of Responsibility: Passes a request between a chain of objects
  • Command: Encapsulate a command request as an object
  • Iterator: Elements of a collection are accessed sequentially
  • Interpreter: Language elements are included
  • Mediator: Defines simplified communication between classes
  • Memento: Capture and restores an object’s internal state
  • Observer: A way of notifying change to a number of classes
  • State: Alter an object’s behavior when its state changes
  • Strategy: Encapsulates an algorithm inside a class
  • Visitor: Defines a new operation to a class without change
  • Template Method: Defer the exact steps of an algorithm to a subclass.

Benefits Of Design Patterns

  • Design patterns enable large scale ensure of software architectures and also help document systems
  • Patterns help improve developer communication
  • Patter names, form a common vocabulary
  • Pattern helps ease the transition to the Object Oriented technology

Drawbacks Of Design Patterns

  • Patterns do not lead to direct code reuse
  • Patterns are deceptively simple
  • Teams may suffer from pattern overload
  • integrating patterns is a human intensive activity

Suggestions for Effective Use

  • Clearly document when patterns apply and do not apply
  • Directly involve pattern authors with application developers and domain experts
  • Do not overdo patterns. Instead develop strategic domain patterns and reuse existing tactical patterns.