Design Patterns

A design pattern names, abstracts, and identifies the key aspects of a common design structure that makes it useful for creating a reusable object-oriented design. The design pattern identifies the participating classes and instances, their roles and collaborations, and the distribution of responsibilities.

A design pattern has four general elements

  1. Pattern Name. Used to describe the design problem, solution and consequences in a word or two.
  2. Problem. Describes when to apply a certain pattern and explains the problem to be solved and its context. Sometimes, it includes a list of conditions to be met before a pattern can be applied
  3. Solution. Provides an abstract description of the problem and how a general arrangement of elements, i.e. classes, interfaces and objects can solve it. It is not specific to a certain language or implementation because a design pattern acts like a template that can be applied in many situations.
  4. Consequences. Pertains to the limits and trade-offs of applying a design pattern. These usually involve space and time trade-offs. The consequences of a pattern may involve the system's flexibility, portability or extensibility.