SlideShare a Scribd company logo
1 of 38
Design patterns are known as best practices that the programmer can use to solve common problems when designing an
application or system.
Classification of Design Patterns
Creational
Creational patterns provide various object creation mechanisms, which increase flexibility and reuse of
existing code.
Structural
Structural patterns explain how to assemble objects and classes into larger structures while keeping these
structures flexible and efficient.
Behavioral
Behavioral patterns take care of effective communication and the assignment of responsibilities between
objects.
Singleton Design Pattern
Creational(1/4)
Is a creational design pattern that lets you ensure
that a class has only one instance, while providing
a global access point to this instance.
A Singleton encapsulates a unique resource and
makes it readily available throughout the
application
Singleton Design Pattern
Creational(1/4)When we use it ?
- When a class in your program should have just a single
instance available to all clients; for example, a single
database object shared by different parts of the program.
-Similarly, there can be a single configuration manager or
error manager in an application that handles all problems
instead of creating multiple managers.
-Centralise logging staff
Singleton Design Pattern
Creational(1/4)Bad things?
-Create a dependance for other classes who create the
instance
-Classes that depend on singletons are relatively harder
to unit test in isolation.Directly impacting testability and
maintainability
-The Singleton design pattern promotes tight coupling
between the classes in your application
The pattern requires special treatment in a
multithreaded environment so that multiple threads
won’t create a singleton object several times.
Singleton Design Pattern
Creational(1/4)Example
Singleton Design Pattern
Factory Design Pattern
Creational(2/4)
Factory is a creational design pattern that provides an
interface for creating objects in a superclass, but allows
subclasses to alter the type of objects that will be created.
-Allows the consumer to create new objects without having
to know the details of how they're created, or what their
dependencies are -. they only have to give the information
they actually want.
Factory Design Pattern
Creational(2/4)When we use it ?
- You don’t know beforehand the exact types and
dependencies of the objects your code should work with.
-Construction is very complex and you need to reuse it.
- You want to save system resources by reusing existing
objects instead of rebuilding them each time.
Factory Design Pattern
Creational(2/4)When NOT use it ?
- We don’t have any complex creation logic.
if the factory doesn’t make any decision, the creation logic
is very simple or is used only in a single place, the factory
will be a needless abstraction.
Factory Design Pattern
Creational(2/4)
Example
Builder Design Pattern Creational(3/4)
Builder pattern builds a complex object using simple objects
and using a step by step approach.The pattern allows you to
produce different types and representations of an object
using the same construction code.
This builder is independent of other objects.
Builder Design Pattern Creational(3/4)
When we use it ?
-When you want your code to be able to create different
representations of some product.
-When you want isolate complex construction code from the
business logic of the product.
Builder Design Pattern Creational(3/4)
Example
Prototype Design Pattern
Creational(4/4)
Prototype is a creational design pattern that lets you copy
existing objects without making your code dependent on
their classes.
Prototype Design Pattern
Creational(4/4)When we use it ?
-when creation of object directly is costly (heavy process).
For example, an object is to be created after a costly
database operation. We can cache the object, returns its
clone on next request and update the database as and when
needed thus reducing database calls.
Your code shouldn’t depend on the concrete classes of
objects that you need to copy.
Prototype Design Pattern
Creational(4/4)
Example
Decorator Design Pattern Structural(1/3)
Decorator is a structural design pattern that lets you attach
new behaviors to objects by placing these objects inside
special wrapper objects that contain the behaviors.
The decorator pattern allows a user to add new functionality
to an existing object without altering its structure.
Decorator Design Pattern Structural(1/3)
When we use it ?
-When you need to be able to assign extra behaviors to
objects at runtime without breaking the code that uses these
objects.
-When it’s difficult or not possible to extend an object’s
behavior using inheritance.
Decorator Design Pattern Structural(1/3)
Example
Proxy Design Pattern Structural(2/3)
Proxy is a structural design pattern that lets you provide a
substitute or placeholder for another object.
A proxy controls access to the original object, allowing
you to perform something either before or after the
request gets through to the original object.
The proxy could interface to anything: a network
connection, a large object in memory, a file, or some other
resource that is expensive or impossible to duplicate
Proxy Design Pattern Structural(2/3)
When we use it (1/2) ?
you want only specific clients to be able to use the
service object; for instance, when your objects are central
parts of an operating system and clients are various
launched applications (including malicious ones).
The proxy can pass the request to the service object only
if the client’s credentials match some criteria.(control
proxy)
Logging requests (logging proxy). This is when you want
to keep a history of requests to the service object.
The proxy can log each request before passing it to the
service.
Proxy Design Pattern Structural(2/3)
When we use it (2/2) ?
Caching request results (caching proxy). This is when you
need to cache results of client requests and manage the
life cycle of this cache, especially if results are quite large.
The proxy can implement caching for recurring requests
that always generate the same results
Proxy Design Pattern Structural(2/3)
Example
Adapter Design Pattern Structural(3/3)
Adapter is a structural design pattern that allows objects with
incompatible interfaces to collaborate.
This pattern involves a single class which is responsible to join
functionalities of independent or incompatible interfaces.
The Adapter pattern lets you create a middle-layer class that
serves as a translator between your code and a legacy class, a
3rd-party class or any other class with a weird interface.
Adapter Design Pattern Structural(3/3)
When we use it ?
-Use the Adapter class when you want to use some existing
class, but its interface isn’t compatible with the rest of your
code.
-Use the pattern when you want to reuse several existing
subclasses that lack some functionality that can’t be added to
the superclass.
-
Adapter Design Pattern Structural(3/3)
Example
Iterator Design Pattern
Behavioral(1/4)
This pattern is used to get a way to access the elements of a
collection object in a sequential manner without any need to know
its underlying representation. (list, stack, tree, complex data
structures.).
As name implies, iterator helps in traversing the collection of objects
in a defined manner which is useful the client applications.
Iterator Design Pattern
Behavioral(1/4)When we use it ?
-when your collection has a complex data structure under the hood,
but you want to hide its complexity from clients (either for
convenience or security reasons).
-when you want your code to be able to traverse different data
structures or when types of these structures are unknown
beforehand.
Iterator Design Pattern
Behavioral(1/4)
Example
Observer Design Pattern Behavioral(2/4)
Observer is a behavioral design pattern that lets you define a
subscription mechanism to notify multiple objects about any events
that happen to the object they’re observing.
Observer Design Pattern Behavioral(2/4)
When we use it ?
-When some objects in your app must observe others, but only for a
limited time or in specific cases.
-When changes to the state of one object may require changing
other objects, and the actual set of objects is unknown beforehand or
changes dynamically.
Observer Design Pattern Behavioral(2/4)
Example
Command Design Pattern Behavioral(3/4)
Command is a behavioral design pattern that turns a
request into a stand-alone object that contains all
information about the request. This transformation lets
you parameterize methods with different requests, delay
or queue a request’s execution, and support undoable
operations.
Command Design Pattern Behavioral(3/4)
-When you want to queue operations, schedule their
execution, or execute them remotely.
-when you want to implement reversible operations.
(undo/redo, the Command pattern is perhaps the most
popular of all.)
-Use the Command pattern when you want to parametrize
objects with operations.
( you can pass commands as method arguments, store
them inside other objects, switch linked commands at
runtime, etc.)
Command Design Pattern Behavioral(3/4)
Example
Strategy Design Pattern Behavioral (4/4)
Strategy is a behavioral design pattern that lets you
define a family of algorithms, put each of them into a
separate class, and make their objects
interchangeable.
Strategy Design Pattern Behavioral (4/4)
When we use it ?
-you want to use different variants of an algorithm
within an object and be able to switch from one
algorithm to another during runtime.
-you have a lot of similar classes that only differ in
the way they execute some behavior.
Strategy Design Pattern Behavioral (4/4)
Example

More Related Content

What's hot

Creational pattern
Creational patternCreational pattern
Creational patternHimanshu
 
Design Patterns
Design PatternsDesign Patterns
Design Patternssoms_1
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1Shahzad
 
Software Engineering - chp4- design patterns
Software Engineering - chp4- design patternsSoftware Engineering - chp4- design patterns
Software Engineering - chp4- design patternsLilia Sfaxi
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns pptAman Jain
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsMichael Heron
 
Design pattern - Facade Pattern
Design pattern - Facade PatternDesign pattern - Facade Pattern
Design pattern - Facade PatternMudasir Qazi
 
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | EdurekaJava Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | EdurekaEdureka!
 
Gof design pattern
Gof design patternGof design pattern
Gof design patternnaveen kumar
 
PATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsPATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsMichael Heron
 
Prototype design patterns
Prototype design patternsPrototype design patterns
Prototype design patternsThaichor Seng
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural PatternsSameh Deabes
 

What's hot (20)

Creational pattern
Creational patternCreational pattern
Creational pattern
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
 
Software Engineering - chp4- design patterns
Software Engineering - chp4- design patternsSoftware Engineering - chp4- design patterns
Software Engineering - chp4- design patterns
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
 
Design patterns
Design patternsDesign patterns
Design patterns
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
 
Composite pattern
Composite patternComposite pattern
Composite pattern
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 
Prototype pattern
Prototype patternPrototype pattern
Prototype pattern
 
Design pattern - Facade Pattern
Design pattern - Facade PatternDesign pattern - Facade Pattern
Design pattern - Facade Pattern
 
Prototype_pattern
Prototype_patternPrototype_pattern
Prototype_pattern
 
Adapter pattern
Adapter patternAdapter pattern
Adapter pattern
 
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | EdurekaJava Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | Edureka
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
PATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsPATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design Patterns
 
Prototype design patterns
Prototype design patternsPrototype design patterns
Prototype design patterns
 
Observer pattern
Observer patternObserver pattern
Observer pattern
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural Patterns
 
Flyweight pattern
Flyweight patternFlyweight pattern
Flyweight pattern
 

Similar to Design patterns

Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityShubham Narkhede
 
Software Patterns
Software PatternsSoftware Patterns
Software Patternsbonej010
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Luis Valencia
 
Bartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsBartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsJason Townsend, MBA
 
Software design and Architecture.pptx
Software design and Architecture.pptxSoftware design and Architecture.pptx
Software design and Architecture.pptxSHAHZAIBABBAS13
 
ap assignmnet presentation.pptx
ap assignmnet presentation.pptxap assignmnet presentation.pptx
ap assignmnet presentation.pptxAwanAdhikari
 
UML Design Class Diagrams (2014)
UML Design Class Diagrams (2014)UML Design Class Diagrams (2014)
UML Design Class Diagrams (2014)Miriam Ruiz
 
Design Pattern in Software Engineering
Design Pattern in Software Engineering Design Pattern in Software Engineering
Design Pattern in Software Engineering Bilal Hassan
 
C# Design Patterns | Design Pattern Tutorial For Beginners | C# Programming T...
C# Design Patterns | Design Pattern Tutorial For Beginners | C# Programming T...C# Design Patterns | Design Pattern Tutorial For Beginners | C# Programming T...
C# Design Patterns | Design Pattern Tutorial For Beginners | C# Programming T...Simplilearn
 
CSS422 Week2 individual
CSS422 Week2 individualCSS422 Week2 individual
CSS422 Week2 individual19eric76
 
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISESoftware Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISEsreeja_rajesh
 
common design patterns summary.pdf
common design patterns summary.pdfcommon design patterns summary.pdf
common design patterns summary.pdfNikolayRaychev2
 
The 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryThe 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryguestebd714
 
The 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryThe 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryachraf_ing
 

Similar to Design patterns (20)

Design patterns
Design patternsDesign patterns
Design patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
OOP design patterns
OOP design patternsOOP design patterns
OOP design patterns
 
Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur University
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
 
Bartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsBartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design Patterns
 
Software design and Architecture.pptx
Software design and Architecture.pptxSoftware design and Architecture.pptx
Software design and Architecture.pptx
 
ap assignmnet presentation.pptx
ap assignmnet presentation.pptxap assignmnet presentation.pptx
ap assignmnet presentation.pptx
 
UML Design Class Diagrams (2014)
UML Design Class Diagrams (2014)UML Design Class Diagrams (2014)
UML Design Class Diagrams (2014)
 
Design Pattern in Software Engineering
Design Pattern in Software Engineering Design Pattern in Software Engineering
Design Pattern in Software Engineering
 
C# Design Patterns | Design Pattern Tutorial For Beginners | C# Programming T...
C# Design Patterns | Design Pattern Tutorial For Beginners | C# Programming T...C# Design Patterns | Design Pattern Tutorial For Beginners | C# Programming T...
C# Design Patterns | Design Pattern Tutorial For Beginners | C# Programming T...
 
CSS422 Week2 individual
CSS422 Week2 individualCSS422 Week2 individual
CSS422 Week2 individual
 
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISESoftware Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
 
Design patterns
Design patternsDesign patterns
Design patterns
 
common design patterns summary.pdf
common design patterns summary.pdfcommon design patterns summary.pdf
common design patterns summary.pdf
 
The 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryThe 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summary
 
The 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryThe 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summary
 

Recently uploaded

Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 

Recently uploaded (20)

Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 

Design patterns

  • 1. Design patterns are known as best practices that the programmer can use to solve common problems when designing an application or system.
  • 2. Classification of Design Patterns Creational Creational patterns provide various object creation mechanisms, which increase flexibility and reuse of existing code. Structural Structural patterns explain how to assemble objects and classes into larger structures while keeping these structures flexible and efficient. Behavioral Behavioral patterns take care of effective communication and the assignment of responsibilities between objects.
  • 3. Singleton Design Pattern Creational(1/4) Is a creational design pattern that lets you ensure that a class has only one instance, while providing a global access point to this instance. A Singleton encapsulates a unique resource and makes it readily available throughout the application
  • 4. Singleton Design Pattern Creational(1/4)When we use it ? - When a class in your program should have just a single instance available to all clients; for example, a single database object shared by different parts of the program. -Similarly, there can be a single configuration manager or error manager in an application that handles all problems instead of creating multiple managers. -Centralise logging staff
  • 5. Singleton Design Pattern Creational(1/4)Bad things? -Create a dependance for other classes who create the instance -Classes that depend on singletons are relatively harder to unit test in isolation.Directly impacting testability and maintainability -The Singleton design pattern promotes tight coupling between the classes in your application The pattern requires special treatment in a multithreaded environment so that multiple threads won’t create a singleton object several times.
  • 7. Factory Design Pattern Creational(2/4) Factory is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created. -Allows the consumer to create new objects without having to know the details of how they're created, or what their dependencies are -. they only have to give the information they actually want.
  • 8. Factory Design Pattern Creational(2/4)When we use it ? - You don’t know beforehand the exact types and dependencies of the objects your code should work with. -Construction is very complex and you need to reuse it. - You want to save system resources by reusing existing objects instead of rebuilding them each time.
  • 9. Factory Design Pattern Creational(2/4)When NOT use it ? - We don’t have any complex creation logic. if the factory doesn’t make any decision, the creation logic is very simple or is used only in a single place, the factory will be a needless abstraction.
  • 11. Builder Design Pattern Creational(3/4) Builder pattern builds a complex object using simple objects and using a step by step approach.The pattern allows you to produce different types and representations of an object using the same construction code. This builder is independent of other objects.
  • 12. Builder Design Pattern Creational(3/4) When we use it ? -When you want your code to be able to create different representations of some product. -When you want isolate complex construction code from the business logic of the product.
  • 13. Builder Design Pattern Creational(3/4) Example
  • 14. Prototype Design Pattern Creational(4/4) Prototype is a creational design pattern that lets you copy existing objects without making your code dependent on their classes.
  • 15. Prototype Design Pattern Creational(4/4)When we use it ? -when creation of object directly is costly (heavy process). For example, an object is to be created after a costly database operation. We can cache the object, returns its clone on next request and update the database as and when needed thus reducing database calls. Your code shouldn’t depend on the concrete classes of objects that you need to copy.
  • 17. Decorator Design Pattern Structural(1/3) Decorator is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors. The decorator pattern allows a user to add new functionality to an existing object without altering its structure.
  • 18. Decorator Design Pattern Structural(1/3) When we use it ? -When you need to be able to assign extra behaviors to objects at runtime without breaking the code that uses these objects. -When it’s difficult or not possible to extend an object’s behavior using inheritance.
  • 19. Decorator Design Pattern Structural(1/3) Example
  • 20. Proxy Design Pattern Structural(2/3) Proxy is a structural design pattern that lets you provide a substitute or placeholder for another object. A proxy controls access to the original object, allowing you to perform something either before or after the request gets through to the original object. The proxy could interface to anything: a network connection, a large object in memory, a file, or some other resource that is expensive or impossible to duplicate
  • 21. Proxy Design Pattern Structural(2/3) When we use it (1/2) ? you want only specific clients to be able to use the service object; for instance, when your objects are central parts of an operating system and clients are various launched applications (including malicious ones). The proxy can pass the request to the service object only if the client’s credentials match some criteria.(control proxy) Logging requests (logging proxy). This is when you want to keep a history of requests to the service object. The proxy can log each request before passing it to the service.
  • 22. Proxy Design Pattern Structural(2/3) When we use it (2/2) ? Caching request results (caching proxy). This is when you need to cache results of client requests and manage the life cycle of this cache, especially if results are quite large. The proxy can implement caching for recurring requests that always generate the same results
  • 23. Proxy Design Pattern Structural(2/3) Example
  • 24. Adapter Design Pattern Structural(3/3) Adapter is a structural design pattern that allows objects with incompatible interfaces to collaborate. This pattern involves a single class which is responsible to join functionalities of independent or incompatible interfaces. The Adapter pattern lets you create a middle-layer class that serves as a translator between your code and a legacy class, a 3rd-party class or any other class with a weird interface.
  • 25. Adapter Design Pattern Structural(3/3) When we use it ? -Use the Adapter class when you want to use some existing class, but its interface isn’t compatible with the rest of your code. -Use the pattern when you want to reuse several existing subclasses that lack some functionality that can’t be added to the superclass. -
  • 26. Adapter Design Pattern Structural(3/3) Example
  • 27. Iterator Design Pattern Behavioral(1/4) This pattern is used to get a way to access the elements of a collection object in a sequential manner without any need to know its underlying representation. (list, stack, tree, complex data structures.). As name implies, iterator helps in traversing the collection of objects in a defined manner which is useful the client applications.
  • 28. Iterator Design Pattern Behavioral(1/4)When we use it ? -when your collection has a complex data structure under the hood, but you want to hide its complexity from clients (either for convenience or security reasons). -when you want your code to be able to traverse different data structures or when types of these structures are unknown beforehand.
  • 30. Observer Design Pattern Behavioral(2/4) Observer is a behavioral design pattern that lets you define a subscription mechanism to notify multiple objects about any events that happen to the object they’re observing.
  • 31. Observer Design Pattern Behavioral(2/4) When we use it ? -When some objects in your app must observe others, but only for a limited time or in specific cases. -When changes to the state of one object may require changing other objects, and the actual set of objects is unknown beforehand or changes dynamically.
  • 32. Observer Design Pattern Behavioral(2/4) Example
  • 33. Command Design Pattern Behavioral(3/4) Command is a behavioral design pattern that turns a request into a stand-alone object that contains all information about the request. This transformation lets you parameterize methods with different requests, delay or queue a request’s execution, and support undoable operations.
  • 34. Command Design Pattern Behavioral(3/4) -When you want to queue operations, schedule their execution, or execute them remotely. -when you want to implement reversible operations. (undo/redo, the Command pattern is perhaps the most popular of all.) -Use the Command pattern when you want to parametrize objects with operations. ( you can pass commands as method arguments, store them inside other objects, switch linked commands at runtime, etc.)
  • 35. Command Design Pattern Behavioral(3/4) Example
  • 36. Strategy Design Pattern Behavioral (4/4) Strategy is a behavioral design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable.
  • 37. Strategy Design Pattern Behavioral (4/4) When we use it ? -you want to use different variants of an algorithm within an object and be able to switch from one algorithm to another during runtime. -you have a lot of similar classes that only differ in the way they execute some behavior.
  • 38. Strategy Design Pattern Behavioral (4/4) Example

Editor's Notes

  1. A toolkit of typical and tested solutions to common problems in software design. - Even if you never encounter these problems, knowing patterns is still useful because it teaches you how to solve all sorts of problems using principles of object-oriented design. - Design patterns define a common language that you and your teammates can use to communicate more efficiently. You can say, “Oh, just use a Singleton for that,” and everyone will understand the idea behind your suggestion. No need to explain what a singleton is if you know the pattern and its name.
  2. are all about class instantiation or object creation. [Singelton / Factory /builder / Prototype ] are about organizing different classes and objects to form larger structures and provide new functionality. [ Decorator / Proxy /Adapter ] about identifying common communication patterns between objects [iterator / Observer /Command /Strategy]