0% found this document useful (0 votes)
481 views46 pages

Design Patterns From Zero To Hero

The document provides an overview of design patterns, including the different categories (creational, structural, behavioral) and examples of patterns within each category. It summarizes each pattern, provides links to detailed explanations and code demos. It is presented by a software engineer who is sharing this knowledge to help others learn design patterns.

Uploaded by

ads ads
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
481 views46 pages

Design Patterns From Zero To Hero

The document provides an overview of design patterns, including the different categories (creational, structural, behavioral) and examples of patterns within each category. It summarizes each pattern, provides links to detailed explanations and code demos. It is presented by a software engineer who is sharing this knowledge to help others learn design patterns.

Uploaded by

ads ads
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 46

DESIGN PATTERNS FROM

ZERO TO HERO
Atanas Vasilev
LinkedIn: https://www.linkedin.com/in/atanas-vasilev-it/
GitHub: https://github.com/NaskoVasilev
Demo Code Link: https://
github.com/NaskoVasilev/Design-Patterns
TABLE OF CONTENTS

• Introduction
• Groups of design patterns
• Creational
• Structural
• Behavioral
• Dive into design patterns one by one
• Theory
• Real world example
• Link to detailed article
• Demo
HAVE A QUESTION?

sli.do
#DesignPatterns
ABOUT ME

• Software engineer
• Full-stack developer in SoftUni Dev team
• Laureate of the National Olympiad in Information Technology
• C# and JS tracks in SoftUni
• Studying Software engineering at FMI in Sofia University (second year)
• Take part in a lot of Information Technology contests
• Started learning programming at the age of 14
WHAT ARE DESIGN PATTERNS?

• Reusable solutions to common problems


• Template for solving given problems
• About interactions of objects
• Solves problems like
• Abstraction
• Encapsulation
• Separation of concerns
• Coupling and cohesion
BENEFITS

• Pattern names form a common vocabulary


• Tried and tested solutions to common problems
• Enable large-scale reuse of software architectures
• Help improve developer communication
• Can speed-up the development
DRAWBACKS

• Developers may suffer from pattern overload and overdesign


• Unjustified use
• “If all you have is a hammer, everything looks like a nail.”
• Inefficient solution if you do not adapt well the pattern to your project
• Not so simple
GROUPS OF DESIGN PATTERNS

• Creational design patterns


• Deal with initialization and configuration of classes and objects
• Object creation mechanisms that increase flexibility and reuse of existing code
• Structural design patterns
• All about Class and Object composition
• Describe ways to assemble objects to implement new functionality
• Behavioral design patterns
• Concerned with interaction between the objects
•  Take care of effective communication between the objects
CREATIONAL DESIGN PATTERNS
LIST OF CREATIONAL DESIGN PATTERNS

• Abstract Factory
• Builder
• Factory Method
• Factory
• Prototype
• Singleton
SINGLETON(1)
• Ensure that a class has only one instance
• https://refactoring.guru/design-patterns/singleton
• https://github.com/NaskoVasilev/Design-Patterns/tree/master/CreationalPatterns/Singleton
SINGLETON(2)
ABSTRACT FACTORY(1)
• Produce families of related objects without specifying their concrete classes
• https://refactoring.guru/design-patterns/abstract-factory
• https://github.com/NaskoVasilev/Design-Patterns/tree/master/CreationalPatterns/AbstractFactory
ABSTRACT FACTORY(2)
BUILDER(1)

• Construct complex objects step by step


• https://refactoring.guru/design-patterns/builder
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/CreationalPatterns/Builder
BUILDER(2)
FACTORY METHOD

•  Provides an interface for creating objects in a superclass, but


allows subclasses to alter the type of objects that will be created
• https://refactoring.guru/design-patterns/factory-method
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/Creational
Patterns/FactoryMethod
PROTOTYPE
•  Copy existing objects without making your code dependent on their classes
• https://refactoring.guru/design-patterns/prototype
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/CreationalPatterns/Prototype
STRUCTURAL DESIGN PATTERNS
LIST OF STRUCTURAL DESIGN PATTERNS

• Adapter
• Bridge
• Composite
• Decorator
• Façade
• Flyweight
• Proxy
ADAPTER(1)
• Allows objects with incompatible interfaces to collaborate
• https://refactoring.guru/design-patterns/adapter
• https://github.com/NaskoVasilev/Design-Patterns/tree/master/StructuralPatterns/Adapter
ADAPTER(2)
DECORATOR(1)

• Attach new behaviors to objects by placing these objects inside special wrapper
objects that contain the behaviors
• https://refactoring.guru/design-patterns/decorator
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/StructuralPatterns/Decor
ator
DECORATOR(2)
FAÇADE(1)

• Provides a simplified interface to a library, a framework, or any other complex set


of classes
• https://refactoring.guru/design-patterns/facade
• https://github.com/NaskoVasilev/Design-Patterns/tree/master/StructuralPatterns/Facade
FAÇADE(2)
BRIDGE

• Split a large class or a set of closely related classes into two separate hierarchies -
abstraction and implementation - which can be developed independently of each other
• https://github.com/NaskoVasilev/Design-Patterns/tree/master/StructuralPatterns/Bridge
• https://refactoring.guru/design-patterns/bridge
COMPOSITE

• Compose objects into tree structures and then work


with these structures as if they were individual objects
• https://refactoring.guru/design-patterns/composite
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/
StructuralPatterns/Composite
PROXY

• Provide a substitute or placeholder for another object


• Controls access to the original object, allowing you to perform
something either before or after the request gets through to the
original object
• https://refactoring.guru/design-patterns/proxy
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/StructuralPatterns
/Proxy
BEHAVIORAL DESIGN PATTERNS
LIST OF BEHAVIORAL DESIGN PATTERNS (1)

• Chain Of Responsibility
• Command
• Interpreter
• Iterator
• Mediator
• Memento
LIST OF BEHAVIORAL DESIGN PATTERNS(2)

• Observer
• State
• Strategy
• Template Method
• Visitor
ITERATOR(1)

• Lets you traverse elements of a collection without exposing its underlying representation
• https://refactoring.guru/design-patterns/iterator
• https://github.com/NaskoVasilev/Design-Patterns/tree/master/BehavioralPatterns/Iterator
ITERATOR(2)
CHAIN OF RESPONSIBILITY(1)

• Pass requests along a chain of handlers


• Upon receiving a request, each handler decides either to process the request
or to pass it to the next handler in the chain
• https://refactoring.guru/design-patterns/chain-of-responsibility
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/BehavioralPatterns/C
hainOfResponsibility
CHAIN OF RESPONSIBILITY(2)
MEDIATOR(1)

• Reduce chaotic dependencies between objects


• Restricts direct communications between the objects and forces them to
collaborate only via a mediator object
• https://refactoring.guru/design-patterns/mediator
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/BehavioralPatterns/M
ediator
S
MEDIATOR(2)
COMMAND

•  Turns a request into a stand-alone object that contains all information about
the request
•  Can pass requests as a method arguments, delay or queue a request’s execution
• https://refactoring.guru/design-patterns/command
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/BehavioralPatterns/Com
mand
MEMENTO

• Also known as Snapshot


• Save and restore the previous state of an object
• https://refactoring.guru/design-patterns/memento
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/BehavioralPatterns/M
emento
OBSERVER
• Also know as: Event-Subscriber, Listener
• Define a subscription mechanism to notify multiple objects about any events that
happen to the object they’re observing
• Observables in Angular
• https://refactoring.guru/design-patterns/observer
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/BehavioralPatterns/Observer
STATE

• Lets an object alter its behavior when its internal state changes
• https://refactoring.guru/design-patterns/state
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/BehavioralPatterns/St
ate
STRATEGY

• Define a family of algorithms, put each of them into a separate class, and
make their objects interchangeable
• https://refactoring.guru/design-patterns/strategy
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/BehavioralPatterns/Str
ategy
TEMPLATE METHOD

• Defines the skeleton of an algorithm in the superclass but lets subclasses


override specific steps of the algorithm without changing its structure
• https://refactoring.guru/design-patterns/template-method
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/BehavioralPatterns/Te
mplateMethod
VISITOR

• Separate algorithms from the objects on which they operate


• https://refactoring.guru/design-patterns/visitor
• https://
github.com/NaskoVasilev/Design-Patterns/tree/master/BehavioralPatterns/Vi
sitor
БЛАГОДАРЯ ВИ ЗА ВНИМАНИЕТО!

You might also like