Skip to content

Introduction

A pattern (or design pattern) is a written document that describes a general solution to a design problem that occurs repeatedly in many projects.

Generic Structure

  • Name that describes the pattern
  • Problem to be solved by the pattern
  • Context, or settings, in which the problem occurs
  • Solution proposed to the problem
  • Context for the solution
  • Author and date information
  • Sample code related to the solution, if it helps

Structure of Design Pattern

Term Description
Pattern Name Describes the essence of the pattern in a short, but expressive, name
Intent Describes what the pattern does
Also Known As List any synonyms for the pattern
Motivation Provides an example of a problem and how the pattern solves that problem
Applicability Lists the situations where the pattern is applicable
Structure Set of diagrams of the classes and objects that depict the pattern
Participants Describes the classes and objects that participate in the design pattern and their responsibilities
Collaborations Describes how the participants collaborate to carry out their responsibilities
Consequences Describes the forces that exist with the pattern and the benefits, trade-offs, and the variable that is isolated by the pattern

Importance of Design Patterns

  • It makes code reusable, bug-free, and clean.
  • Speed up development process.
  • Changes or modification become easier.
  • Reduce common problems of developers they face during development process.
  • Improve object oriented skill.
  • Easy to understand the flow of code.
  • Less code so easy to maintain.