# Topic covered
* Design Pattern
* Design Pattern vs Algorithms
* Classification of patterns
  * Creational patterns
  * Structural patterns
  * Behavioral patterns

5.1 Design Pattern

Patterns are typical solutions to common problems in object-oriented design. They are like pre-made blueprints that you can customize to solve a recurring design problem in your code.

When a solution gets repeated over and over in various projects, someone eventually puts a name to it

Design pattern is a walkthrough of a well-tested approach that can be used to solve a generally occurring and recurring problem in object-oriented software design.

Common problems like - how to create classes, instantiate class, structure them, communicate between them.

5.2 Design Pattern vs Algorithms

Patterns are often confused with algorithms, because both concepts describe typical solutions to some known problems.

While an algorithm always defines a clear set of actions that can achieve some goal, a pattern is a more high-level description of a solution. The code of the same pattern applied to two different programs may be different

5.3 Classification of patterns

Classification of patterns

  1. Creational patterns
    • Deals with creation and instantiation of objects.
    • It provides object creation mechanisms that increase flexibility and reuse of existing code.
  2. Structural patterns
    • Deals with how to structure, organize the class/objects (eg - class members)
    • It explains how to assemble objects and classes into larger structures, while keeping the structures flexible and efficient.
  3. Behavioral patterns
    • Deals with how objects or components communicate with each other.
    • It takes care of how objects or components communicate with each other as well as how they share responsibilities

Types of patterns

# Creational
Factory Method(Class)
Abstract Factory
Builder
Prototype
Singleton
# Structural
Adapter(Class)
Adapter(Object)
Bridge
Composite
Decorator
Flyweight
Proxy
Facade
# Behavioral
Interpreter(Class)
Template Method(Class)
Observer
Chain of responsibility
Command
Iterator

Reference