# 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
- Creational patterns
- Deals with
creation and instantiation
of objects. - It provides
object creation
mechanisms thatincrease flexibility and reuse
of existing code.
- Deals with
- 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.
- Deals with how to
- 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 theyshare responsibilities
- Deals with how
# 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
- https://www.scaler.com/topics/design-patterns/what-are-design-patterns/
- Youtube: Keerti Purswani - Design Pattern
- YouTube: sudoCode - Design Pattern
- https://sourcemaking.com/design_patterns
- https://blog.bytebytego.com/p/ep17-design-patterns-cheat-sheet
- https://www.youtube.com/watch?v=v9ejT8FO-7I&list=PLrhzvIcii6GNjpARdnO4ueTUAVR9eMBpc
- https://www.youtube.com/watch?v=vNHpsC5ng_E&list=PLF206E906175C7E07