# Basics

## What is a Design pattern?

* Design patterns are the best **formalized practices** a programmer can use to solve common problems when designing an application or system.

## Why do we need them?

* Design patterns can speed up the development process by providing tested, proven development paradigms.
* Reusing design patterns help prevent subtle issues that cause major problems, and it also improves code readability for coders and architects who are familiar with the patterns.
* It provides vocabulary, so that the developer can communicate the problem statement and their solutions.

## Gamma Categorization

* The notion of design pattern was introduced by Gang of Four book, and as per the authors the design patterns are categorized as follows,
  * **Creational**
    * Deals with construction of object.
    * Provides with explicit _(constructor based)_ and implicit _(DI and reflection)_ ways.
    * Whole _(Single statement)_ versus piecewise _(step by step)_ construction.
    * This gives the program more flexibility in deciding which objects need to be created for a given case.
    * _**Patterns**_
      * Abstract Factory
      * Builder
      * Factory Method
      * Prototype
      * Singleton
  * **Structural**
    * They use inheritance to compose interfaces and define ways to compose objects to obtain new functionality.
    * Many patterns provides ways to mimic the underlying class' interface.
    * Important is given on creating good API design.
    * _**Patterns**_
      * Adapter
      * Bridge
      * Composite
      * Decorator
      * Façade
      * Flyweight
      * Proxy
  * **Behavioral**
    * Most of these design patterns are specifically concerned with communication between objects.
    * _**Patterns**_
      * Chain of Responsibility
      * Command
      * Interpreter
      * Iterator
      * Mediator
      * Memento
      * Observer
      * State
      * Strategy
      * Template Method
      * Visitor
* References:
  * [Wikipedia](https://en.wikipedia.org/wiki/Design_Patterns)
  * [Baeldung](https://www.baeldung.com/)
  * [Gof Patterns](http://w3sdesign.com/?gr=c04\&ugr=proble#gf)
  * [List of Design Pattern Implementation in Java](https://java-design-patterns.com/patterns/)
