SlideShare a Scribd company logo
1 of 2
+visitElementA(in a : ConcreteElementA)
+visitElementB(in b : ConcreteElementB)
«interface»
Visitor
+visitElementA(in a : ConcreteElementA)
+visitElementB(in b : ConcreteElementB)
ConcreteVisitor +accept(in v : Visitor)
«interface»
Element
+accept(in v : Visitor)
ConcreteElementA
+accept(in v : Visitor)
ConcreteElementB
Client
Visitor
Type: Behavioral
What it is:
Represent an operation to be
performed on the elements of an
object structure. Lets you define a
new operation without changing
the classes of the elements on
which it operates.
+templateMethod()
#subMethod()
AbstractClass
+subMethod()
ConcreteClass
Template Method
Type: Behavioral
What it is:
Define the skeleton of an algorithm in an
operation, deferring some steps to subclasses.
Lets subclasses redefine certain steps
of an algorithm without changing the
algorithm's structure.
+execute()
ConcreteStrategyB
+execute()
«interface»
Strategy
Context
+execute()
ConcreteStrategyA
Strategy
Type: Behavioral
What it is:
Define a family of algorithms,
encapsulate each one, and make them
interchangeable. Lets the algorithm vary
independently from
clients that use it.
+handle()
ConcreteState1
+handle()
«interface»
State
+request()
Context
+handle()
ConcreteState2
State
Type: Behavioral
What it is:
Allow an object to alter its behavior when
its internal state changes. The object will
appear to change its class.
-subjectState
ConcreteSubject
+update()
-observerState
ConcreteObserver
+update()
«interface»
Observer
notifies
observes
+attach(in o : Observer)
+detach(in o : Observer)
+notify()
«interface»
Subject
Observer
Type: Behavioral
What it is:
Define a one-to-many dependency between
objects so that when one object changes
state, all its dependents are notified and
updated automatically.
-state
Memento
+setMemento(in m : Memento)
+createMemento()
-state
Originator
Caretaker
Memento
Type: Behavioral
What it is:
Without violating encapsulation, capture
and externalize an object's internal state
so that the object can be restored to this
state later.
Abstract Factory
C
Adapter
S
Bridge
S
Builder
C
Chain of Responsibility
B
Command
B
Composite
S
Decorator
S
Facade
S
Factory Method
C
Flyweight
S
Interpreter
B
Iterator
B
Mediator
B
Memento
B
Prototype
C
Proxy
S
Observer
B
Singleton
C
State
B
Strategy
B
Template Method
B
Visitor
B
Chain of Responsibility
+handleRequest()
«interface»
Handler
+handleRequest()
ConcreteHandler1
+handleRequest()
ConcreteHandler2
Client
successor
Type: Behavioral
What it is:
Avoid coupling the sender of a request to
its receiver by giving more than one object
a chance to handle the request. Chain the
receiving objects and pass the request
along the chain until an object handles it.
+execute()
ConcreteCommand
Client
+action()
Receiver
Invoker Command
Type: Behavioral
What it is:
Encapsulate a request as an object,
thereby letting you parameterize clients
with different requests, queue or log
requests, and support undoable operations.
+interpret()
«interface»
AbstractExpression
+interpret() : Context
TerminalExpression
Client
Context
+interpret() : Context
NonterminalExpression
Interpreter
Type: Behavioral
What it is:
Given a language, define a representation
for its grammar along with an interpreter
that uses the representation to interpret
sentences in the language.
+createIterator()
«interface»
Aggregate
+createIterator() : Context
ConcreteAggregate
+next()
«interface»
Iterator
+next() : Context
ConcreteIterator
Iterator
Type: Behavioral
What it is:
Provide a way to access the elements of
an aggregate object sequentially without
exposing its underlying representation.
Client
Mediator
ConcreteMediator ConcreteColleague
«interface»
Colleague
informs
updates
Mediator
Type: Behavioral
What it is:
Define an object that encapsulates how a
set of objects interact. Promotes loose
coupling by keeping objects from referring
to each other explicitly and it lets you vary
their interactions independently.
Copyright © 2007 Jason S. McDonald
http://www.McDonaldLand.info
Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1995). Design Patterns: Elements of
Reusable Object-Oriented Software. Reading, Massachusetts: Addison Wesley Longman, Inc..
+execute()
Command
Facade
Complex system
Adapter
Type: Structural
What it is:
Convert the interface of a class into
another interface clients expect. Lets
classes work together that couldn't
otherwise because of incompatible
interfaces.
+adaptedOperation()
Adaptee
+operation()
«interface»
Adapter
+operation()
-adaptee
ConcreteAdapter
Client
+operationImpl()
«interface»
Implementor
+operation()
Abstraction
+operationImpl()
ConcreteImplementorA
+operationImpl()
ConcreteImplementorB
Bridge
Type: Structural
What it is:
Decouple an abstraction from its
implementation so that the two can vary
independently.
+operation()
Leaf +operation()
+add(in c : Composite)
+remove(in c : Composite)
+getChild(in i : int)
Composite
+operation()
+add(in c : Composite)
+remove(in c : Composite)
+getChild(in i : int)
«interface»
Component
children
Composite
Type: Structural
What it is:
Compose objects into tree structures to
represent part-whole hierarchies. Lets
clients treat individual objects and
compositions of objects uniformly.
+operation()
ConcreteComponent
+operation()
Decorator
+operation()
«interface»
Component
+operation()
+addedBehavior()
-addedState
ConcreteDecorator
Decorator
Type: Structural
What it is:
Attach additional responsibilities to an
object dynamically. Provide a flexible
alternative to sub-classing for extending
functionality.
Facade
Type: Structural
What it is:
Provide a unified interface to a set of
interfaces in a subsystem. Defines a high-
level interface that makes the subsystem
easier to use.
Flyweight
Type: Structural
What it is:
Use sharing to support large numbers of
fine grained objects efficiently.
+request()
RealSubject
+request()
Proxy
+request()
«interface»
Subject
Client
represents
Proxy
Type: Structural
What it is:
Provide a surrogate or placeholder for
another object to control access to it.
+static instance()
+SingletonOperation()
-static uniqueInstance
-singletonData
Singleton
Singleton
Type: Creational
What it is:
Ensure a class only has one instance and
provide a global point of access to it.
+clone()
ConcretePrototype2
+clone()
«interface»
Prototype
Client
+clone()
ConcretePrototype1
Prototype
Type: Creational
What it is:
Specify the kinds of objects to create
using a prototypical instance, and
create new objects by copying this
prototype.
«interface»
Product
ConcreteProduct
+factoryMethod()
ConcreteCreator
+factoryMethod()
+anOperation()
Creator
Factory Method
Type: Creational
What it is:
Define an interface for creating an
object, but let subclasses decide which
class to instantiate. Lets a class defer
instantiation to subclasses.
+buildPart()
«interface»
Builder
+buildPart()
+getResult()
ConcreteBuilder
+construct()
Director
Builder
Type: Creational
What it is:
Separate the construction of a
complex object from its representing
so that the same construction
process can create different
representations.
«interface»
AbstractProduct
ConcreteProduct
+createProductA()
+createProductB()
«interface»
AbstractFactory
+createProductA()
+createProductB()
ConcreteFactory
Client
Abstract Factory
Type: Creational
What it is:
Provides an interface for creating
families of related or dependent
objects without specifying their
concrete class.
+operation(in extrinsicState)
-intrinsicState
ConcreteFlyweight
+operation(in extrinsicState)
-allState
UnsharedConcreteFlyweight
+operation(in extrinsicState)
«interface»
Flyweight
+getFlyweight(in key)
FlyweightFactory
Client
Copyright © 2007 Jason S. McDonald
http://www.McDonaldLand.info
Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1995). Design Patterns: Elements of
Reusable Object-Oriented Software. Reading, Massachusetts: Addison Wesley Longman, Inc..

More Related Content

Similar to Unveiling Design Patterns: A Visual Guide with UML Diagrams

react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryjanet736113
 
SwiftUI와 TCA로 GitHub Search앱 만들기
SwiftUI와 TCA로 GitHub Search앱 만들기SwiftUI와 TCA로 GitHub Search앱 만들기
SwiftUI와 TCA로 GitHub Search앱 만들기규영 허
 
Overview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyOverview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyPeter R. Egli
 
Validate your entities with symfony validator and entity validation api
Validate your entities with symfony validator and entity validation apiValidate your entities with symfony validator and entity validation api
Validate your entities with symfony validator and entity validation apiRaffaele Chiocca
 
Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Paulo Gandra de Sousa
 
Reactive clean architecture
Reactive clean architectureReactive clean architecture
Reactive clean architectureViktor Nyblom
 
Il 09 T3 William Spreitzer
Il 09 T3 William SpreitzerIl 09 T3 William Spreitzer
Il 09 T3 William Spreitzerwspreitzer
 
GWT.create 2013: Introduction to GXT
GWT.create 2013: Introduction to GXTGWT.create 2013: Introduction to GXT
GWT.create 2013: Introduction to GXTniloc132
 
PDC Video on C# 4.0 Futures
PDC Video on C# 4.0 FuturesPDC Video on C# 4.0 Futures
PDC Video on C# 4.0 Futuresnithinmohantk
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84Mahmoud Samir Fayed
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Jonas Follesø
 

Similar to Unveiling Design Patterns: A Visual Guide with UML Diagrams (20)

react-slides.pdf
react-slides.pdfreact-slides.pdf
react-slides.pdf
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
 
1204csharp
1204csharp1204csharp
1204csharp
 
SwiftUI와 TCA로 GitHub Search앱 만들기
SwiftUI와 TCA로 GitHub Search앱 만들기SwiftUI와 TCA로 GitHub Search앱 만들기
SwiftUI와 TCA로 GitHub Search앱 만들기
 
Overview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyOverview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technology
 
Validate your entities with symfony validator and entity validation api
Validate your entities with symfony validator and entity validation apiValidate your entities with symfony validator and entity validation api
Validate your entities with symfony validator and entity validation api
 
PoEAA by Example
PoEAA by ExamplePoEAA by Example
PoEAA by Example
 
Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)
 
Reactive clean architecture
Reactive clean architectureReactive clean architecture
Reactive clean architecture
 
2.dynamic
2.dynamic2.dynamic
2.dynamic
 
Interface
InterfaceInterface
Interface
 
Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)
 
Il 09 T3 William Spreitzer
Il 09 T3 William SpreitzerIl 09 T3 William Spreitzer
Il 09 T3 William Spreitzer
 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
 
GWT.create 2013: Introduction to GXT
GWT.create 2013: Introduction to GXTGWT.create 2013: Introduction to GXT
GWT.create 2013: Introduction to GXT
 
PDC Video on C# 4.0 Futures
PDC Video on C# 4.0 FuturesPDC Video on C# 4.0 Futures
PDC Video on C# 4.0 Futures
 
Design Pattern Cheatsheet
Design Pattern CheatsheetDesign Pattern Cheatsheet
Design Pattern Cheatsheet
 
Intake 37 linq3
Intake 37 linq3Intake 37 linq3
Intake 37 linq3
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
 

Recently uploaded

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
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
 
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
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
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
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
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
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
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
 
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
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 

Recently uploaded (20)

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
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...
 
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
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
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
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
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
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
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...
 
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...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

Unveiling Design Patterns: A Visual Guide with UML Diagrams

  • 1. +visitElementA(in a : ConcreteElementA) +visitElementB(in b : ConcreteElementB) «interface» Visitor +visitElementA(in a : ConcreteElementA) +visitElementB(in b : ConcreteElementB) ConcreteVisitor +accept(in v : Visitor) «interface» Element +accept(in v : Visitor) ConcreteElementA +accept(in v : Visitor) ConcreteElementB Client Visitor Type: Behavioral What it is: Represent an operation to be performed on the elements of an object structure. Lets you define a new operation without changing the classes of the elements on which it operates. +templateMethod() #subMethod() AbstractClass +subMethod() ConcreteClass Template Method Type: Behavioral What it is: Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure. +execute() ConcreteStrategyB +execute() «interface» Strategy Context +execute() ConcreteStrategyA Strategy Type: Behavioral What it is: Define a family of algorithms, encapsulate each one, and make them interchangeable. Lets the algorithm vary independently from clients that use it. +handle() ConcreteState1 +handle() «interface» State +request() Context +handle() ConcreteState2 State Type: Behavioral What it is: Allow an object to alter its behavior when its internal state changes. The object will appear to change its class. -subjectState ConcreteSubject +update() -observerState ConcreteObserver +update() «interface» Observer notifies observes +attach(in o : Observer) +detach(in o : Observer) +notify() «interface» Subject Observer Type: Behavioral What it is: Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. -state Memento +setMemento(in m : Memento) +createMemento() -state Originator Caretaker Memento Type: Behavioral What it is: Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later. Abstract Factory C Adapter S Bridge S Builder C Chain of Responsibility B Command B Composite S Decorator S Facade S Factory Method C Flyweight S Interpreter B Iterator B Mediator B Memento B Prototype C Proxy S Observer B Singleton C State B Strategy B Template Method B Visitor B Chain of Responsibility +handleRequest() «interface» Handler +handleRequest() ConcreteHandler1 +handleRequest() ConcreteHandler2 Client successor Type: Behavioral What it is: Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it. +execute() ConcreteCommand Client +action() Receiver Invoker Command Type: Behavioral What it is: Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. +interpret() «interface» AbstractExpression +interpret() : Context TerminalExpression Client Context +interpret() : Context NonterminalExpression Interpreter Type: Behavioral What it is: Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language. +createIterator() «interface» Aggregate +createIterator() : Context ConcreteAggregate +next() «interface» Iterator +next() : Context ConcreteIterator Iterator Type: Behavioral What it is: Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation. Client Mediator ConcreteMediator ConcreteColleague «interface» Colleague informs updates Mediator Type: Behavioral What it is: Define an object that encapsulates how a set of objects interact. Promotes loose coupling by keeping objects from referring to each other explicitly and it lets you vary their interactions independently. Copyright © 2007 Jason S. McDonald http://www.McDonaldLand.info Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1995). Design Patterns: Elements of Reusable Object-Oriented Software. Reading, Massachusetts: Addison Wesley Longman, Inc.. +execute() Command
  • 2. Facade Complex system Adapter Type: Structural What it is: Convert the interface of a class into another interface clients expect. Lets classes work together that couldn't otherwise because of incompatible interfaces. +adaptedOperation() Adaptee +operation() «interface» Adapter +operation() -adaptee ConcreteAdapter Client +operationImpl() «interface» Implementor +operation() Abstraction +operationImpl() ConcreteImplementorA +operationImpl() ConcreteImplementorB Bridge Type: Structural What it is: Decouple an abstraction from its implementation so that the two can vary independently. +operation() Leaf +operation() +add(in c : Composite) +remove(in c : Composite) +getChild(in i : int) Composite +operation() +add(in c : Composite) +remove(in c : Composite) +getChild(in i : int) «interface» Component children Composite Type: Structural What it is: Compose objects into tree structures to represent part-whole hierarchies. Lets clients treat individual objects and compositions of objects uniformly. +operation() ConcreteComponent +operation() Decorator +operation() «interface» Component +operation() +addedBehavior() -addedState ConcreteDecorator Decorator Type: Structural What it is: Attach additional responsibilities to an object dynamically. Provide a flexible alternative to sub-classing for extending functionality. Facade Type: Structural What it is: Provide a unified interface to a set of interfaces in a subsystem. Defines a high- level interface that makes the subsystem easier to use. Flyweight Type: Structural What it is: Use sharing to support large numbers of fine grained objects efficiently. +request() RealSubject +request() Proxy +request() «interface» Subject Client represents Proxy Type: Structural What it is: Provide a surrogate or placeholder for another object to control access to it. +static instance() +SingletonOperation() -static uniqueInstance -singletonData Singleton Singleton Type: Creational What it is: Ensure a class only has one instance and provide a global point of access to it. +clone() ConcretePrototype2 +clone() «interface» Prototype Client +clone() ConcretePrototype1 Prototype Type: Creational What it is: Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype. «interface» Product ConcreteProduct +factoryMethod() ConcreteCreator +factoryMethod() +anOperation() Creator Factory Method Type: Creational What it is: Define an interface for creating an object, but let subclasses decide which class to instantiate. Lets a class defer instantiation to subclasses. +buildPart() «interface» Builder +buildPart() +getResult() ConcreteBuilder +construct() Director Builder Type: Creational What it is: Separate the construction of a complex object from its representing so that the same construction process can create different representations. «interface» AbstractProduct ConcreteProduct +createProductA() +createProductB() «interface» AbstractFactory +createProductA() +createProductB() ConcreteFactory Client Abstract Factory Type: Creational What it is: Provides an interface for creating families of related or dependent objects without specifying their concrete class. +operation(in extrinsicState) -intrinsicState ConcreteFlyweight +operation(in extrinsicState) -allState UnsharedConcreteFlyweight +operation(in extrinsicState) «interface» Flyweight +getFlyweight(in key) FlyweightFactory Client Copyright © 2007 Jason S. McDonald http://www.McDonaldLand.info Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1995). Design Patterns: Elements of Reusable Object-Oriented Software. Reading, Massachusetts: Addison Wesley Longman, Inc..