SlideShare a Scribd company logo
Design Pattern
         By Julie Iskander
MSc. Communication and Electronics
Outlines
                   Lecture 4
• Behavioral Design Patterns
 •   Chain of Responsibility
 •   Command
 •   Mediator
 •   Memento
 •   Observer
 •   State
 •   Strategy
 •   Template Method
 •   Interpreter
 •   Visitor
 •   Iterator (Reading Assignment)
Behavioral Patterns
Chain of responsibility DP
• What
  • A replication of the business or functional process of
    delegating responsibility within a hierarchy.
• Where
  • A requirement to manage tasks by coordinating objects and
    have them cooperate within a hierarchical structure.
• Why
  • Avoid coupling sender of request to receiver
• How
  • An abstract class that represents a participant or link is sub-
    classed into a set of links, and then the sub-classed links
    implement the functionality that represents their responsibility
    and can trigger the passing on of a requirement. The client
    determines the hierarchy among the links and initiates
    passing the requirement to the chain.
Chain of responsibility dp
Chain of responsibility dp
Chain of responsibility dp
Chain of responsibility
Chain of responsibility
Command DP
(object - Behavioral DP)
Command DP
         (object - Behavioral DP)
• What
 • Encapsulate a request as an object, and support
   undoable operations.

• Where
 • To issue requests to objects without knowing anything
   about the operation being requested or the receiver of the
   request.

• Why
 • specify, queue, and execute requests at different
   times. support undo. support logging changes
Command DP
(object - Behavioral DP)
Command DP
(object - Behavioral DP)
Command DP
(object - Behavioral DP)
Command DP
(object - Behavioral DP)
Command DP
      (object - Behavioral DP)
• Supporting undo and redo:
 • Must provide a reverse method (Unexecute/Undo).
 • Might need to store additional state like the Receiver
   object, the arguments to the operation performed on
   the receiver, and any original values in the receiver that
   can change as a result of handling the request.
 • For one level of undo, store only the last executed
   command.
 • For multi-level undo, store a history list of executed
   commands.
Mediator DP
         (object - Behavioral DP)
• What
  • Define an object that encapsulates how a set of objects
    interact. Mediator promotes loose coupling by keeping objects
    from referring to each other explicitly, and it lets you vary their
    interaction independently.
• Where
  • when many objects interconnect, to lessen the coupling
• Why
  • To lessen the coupling between objects
• How
  • Encapsulating collective behavior in a separate mediator
    object. A mediator is responsible for controlling and
    coordinating the interactions of a group of objects. The
    objects only know the mediator, thereby reducing the number
    of interconnections.
Mediator DP
(object - Behavioral DP)
Mediator DP
(object - Behavioral DP)
Mediator DP
(object - Behavioral DP)
Mediator DP
(object - Behavioral DP)
Mediator DP
(object - Behavioral DP)
Mediator DP
(object - Behavioral DP)
Mediator DP
     (object - Behavioral DP)
• Façade make requests to the
  subsystem, while mediator enables
  cooperative behaviour between colleagues
  objects
MeMento DP
         (object - Behavioral DP)
• What
 • capture and externalize an object's internal state so
   that the object can be restored to this state later.

• Where
 • To store a snapshot of internal state of an object, to
   implement checkpoints

• Why
 • To implement checkpoints, save state, undo
   mechanisms

• How
MeMento DP
(object - Behavioral DP)
MeMento DP
(object - Behavioral DP)
MeMento DP
      (object - Behavioral DP)
• Memento objects are passive
• Memento can be used to maintain state for
  undoable operations for Command DP
• Used in Games to store check points
Observer DP
(object - Behavioral DP)
Observer DP
          (object - Behavioral DP)
• What
 • An Observer pattern is a design based on a one-to-many
   relationship, where one is a publisher that publishes an event
   against which many subscribers register an interest.

• Where
 • A requirement to initiate and manage communications among a
   society of objects.

• Why
 • To programmatically establish and manage a set of relationships
   among objects at run time.

• How
 • Create a subject object (publisher) and any number of observer
   objects (subscribers), and then wire an event handler in the observer
   objects to an event in the subject object. In .NET, we use a delegate
   event-handling model to wire the observer objects to the publisher's
   event—delegates simplify the architecture articulated by GoF.
Observer DP
(object - Behavioral DP)
Observer DP
(object - Behavioral DP)
Observer DP
(object - Behavioral DP)
State DP
         (object - Behavioral DP)
• What
 • Allow an object to alter its behavior when its internal
   state changes. The object will appear to change its
   class.
• Where
 • An object's behavior depends on its state, and it
   must change its behavior at run-time depending on
   that state.
• Why
 • This lets you treat the object's state as an object in
   its own right that can vary independently from other
   objects.
State DP
(object - Behavioral DP)
State DP
(object - Behavioral DP)
Strategy DP
          (object-behavioural DP)
• What
  • A design that presents a family of algorithms or business rules
    encapsulated in classes that can be swapped.
• Where
  • A requirement for the contextual implementation of different
    algorithms or business rules without the use of conditional
    code.
• Why
  • A design that separates the choice of algorithm or business
    rule from its implementation and delegates the contextual
    choice of algorithm or business rule to client code.
• How
  • Design an abstract strategy class that includes an abstract
    method from which an algorithm may be called. Prepare a
    context class to contain an abstract strategy class and then
    code the client to choose the strategy and inform the context
Strategy DP
(object-behavioural DP)
Template Method DP
         (Class - Behavioral DP)
• What
 • Need subclasses to house different implementations of an
   algorithm and defer part of the implementation to the
   subclass.

• Where
 • A requirement for a common structure to house an
   algorithm, while vary the implementation of the algorithm.

• Why
 • A default implementation that has the flexibility for a subclass
   to vary the underlying algorithm within the implementation.

• How
 • An abstract class exposes a Template Method that wraps a set
Template Method DP
(Class - Behavioral DP)
Template Method DP
(Class - Behavioral DP)
Template Method DP
     (Class - Behavioral DP)
• Factory Methods are often called by template
  methods. (DoCreateDocument called by
  OpenDocument).
• Template methods use inheritance to vary part of
  an algorithm. Strategies use delegation to vary
  the entire algorithm.
Report #3:

Interpreter DP
Visitor DP

N.B. Hand Written 
References
[1] Design Patterns, Christopher G. Lasater, Wordware Publishing, Inc.

[2] http://www.CodeProject.com, How I explained OOD to my wife, Al-
Farooque Shubho

[3]http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod,PrinciplesOf
Ood

[4]http://www.CodeProject.comHow I explained Design Patterns to my wife:
Part 1,By Al-FarooqueShubho

[5] http://www.shubho.net/2010/09/interface-vs-abstract-class-classic.html,
Al-FarooqueShubho

[6]C# 3.0 Design Patterns, Judith Bishop

[7]Head First Design Pattern, Eric Freeman, Elisabeth Freeman, Kathy
Sierra, Bert Bates

[8] Pro .NET 2.0 Code and Design Standards in C#, Mark Horner
The End
  Thank you
    and
  Good Luck
Ad

More Related Content

What's hot (19)

0-oop java-intro
0-oop java-intro0-oop java-intro
0-oop java-intro
Amr Elghadban (AmrAngry)
 
Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
Prof. Dr. K. Adisesha
 
OOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and ObjectOOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and Object
dkpawar
 
Java Programming Paradigms Chapter 1
Java Programming Paradigms Chapter 1 Java Programming Paradigms Chapter 1
Java Programming Paradigms Chapter 1
Sakthi Durai
 
Chapter 8 java
Chapter 8 javaChapter 8 java
Chapter 8 java
Ahmad sohail Kakar
 
Oops ppt
Oops pptOops ppt
Oops ppt
abhayjuneja
 
Power of introspection
Power of introspectionPower of introspection
Power of introspection
Joseph Jeffrey
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
BG Java EE Course
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
Greg Sohl
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
AnsgarMary
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
deonpmeyer
 
Java essentials for hadoop
Java essentials for hadoopJava essentials for hadoop
Java essentials for hadoop
Seo Gyansha
 
OOPS in Java
OOPS in JavaOOPS in Java
OOPS in Java
Zeeshan Khan
 
Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHP
Rick Ogden
 
Brownfield Domain Driven Design
Brownfield Domain Driven DesignBrownfield Domain Driven Design
Brownfield Domain Driven Design
Nicolò Pignatelli
 
Concepts of OOPs
Concepts of OOPsConcepts of OOPs
Concepts of OOPs
Essay Corp
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
MH Abid
 
Object-Oriented Concepts
Object-Oriented ConceptsObject-Oriented Concepts
Object-Oriented Concepts
Abdalla Mahmoud
 
Flyweight pattern
Flyweight patternFlyweight pattern
Flyweight pattern
Shakil Ahmed
 
OOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and ObjectOOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and Object
dkpawar
 
Java Programming Paradigms Chapter 1
Java Programming Paradigms Chapter 1 Java Programming Paradigms Chapter 1
Java Programming Paradigms Chapter 1
Sakthi Durai
 
Power of introspection
Power of introspectionPower of introspection
Power of introspection
Joseph Jeffrey
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
Greg Sohl
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
AnsgarMary
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
deonpmeyer
 
Java essentials for hadoop
Java essentials for hadoopJava essentials for hadoop
Java essentials for hadoop
Seo Gyansha
 
Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHP
Rick Ogden
 
Brownfield Domain Driven Design
Brownfield Domain Driven DesignBrownfield Domain Driven Design
Brownfield Domain Driven Design
Nicolò Pignatelli
 
Concepts of OOPs
Concepts of OOPsConcepts of OOPs
Concepts of OOPs
Essay Corp
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
MH Abid
 
Object-Oriented Concepts
Object-Oriented ConceptsObject-Oriented Concepts
Object-Oriented Concepts
Abdalla Mahmoud
 

Viewers also liked (7)

Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
Shahriar Hyder
 
Command Pattern in Ruby
Command Pattern in RubyCommand Pattern in Ruby
Command Pattern in Ruby
Jyaasa Technologies
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
Rothana Choun
 
Command Pattern
Command PatternCommand Pattern
Command Pattern
Geoff Burns
 
Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++
ppd1961
 
Command pattern
Command patternCommand pattern
Command pattern
Shakil Ahmed
 
Composite Design Pattern
Composite Design PatternComposite Design Pattern
Composite Design Pattern
Ferdous Mahmud Shaon
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
Shahriar Hyder
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
Rothana Choun
 
Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++
ppd1961
 
Ad

Similar to Design Pattern lecture 4 (20)

Oo concepts and class modeling
Oo concepts and class modelingOo concepts and class modeling
Oo concepts and class modeling
Preeti Mishra
 
CPP Object Oriented Concepts(OOPS).pptx
CPP  Object Oriented Concepts(OOPS).pptxCPP  Object Oriented Concepts(OOPS).pptx
CPP Object Oriented Concepts(OOPS).pptx
adityakumardas16
 
Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2
Julie Iskander
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
RushikeshChikane1
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
RushikeshChikane2
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka Pradhan
Priyanka Pradhan
 
Design Pattern lecture 3
Design Pattern lecture 3Design Pattern lecture 3
Design Pattern lecture 3
Julie Iskander
 
common design patterns summary.pdf
common design patterns summary.pdfcommon design patterns summary.pdf
common design patterns summary.pdf
NikolayRaychev2
 
Introduction
IntroductionIntroduction
Introduction
Preeti Mishra
 
Predictable reactive state management - ngrx
Predictable reactive state management - ngrxPredictable reactive state management - ngrx
Predictable reactive state management - ngrx
Ilia Idakiev
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
anguraju1
 
Ooad ch 2
Ooad ch 2Ooad ch 2
Ooad ch 2
anujabeatrice2
 
Iterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternIterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design pattern
Nitin Bhide
 
Design pattern and their application
Design pattern and their applicationDesign pattern and their application
Design pattern and their application
Hiệp Tiến
 
Marco Mancuso - Data Context Interaction
Marco Mancuso - Data Context InteractionMarco Mancuso - Data Context Interaction
Marco Mancuso - Data Context Interaction
cosenzaLab
 
Style & Design Principles 02 - Design Patterns
Style & Design Principles 02 - Design PatternsStyle & Design Principles 02 - Design Patterns
Style & Design Principles 02 - Design Patterns
Nick Pruehs
 
Design PatternsEECS 3311Song Wang[email protected]ee
Design PatternsEECS 3311Song Wang[email protected]eeDesign PatternsEECS 3311Song Wang[email protected]ee
Design PatternsEECS 3311Song Wang[email protected]ee
LinaCovington707
 
Chapter 02 The Object Model_Software E.ppt
Chapter 02 The Object Model_Software E.pptChapter 02 The Object Model_Software E.ppt
Chapter 02 The Object Model_Software E.ppt
AhammadUllah3
 
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.pptJava Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
akashsachu221
 
01-introductionto Object ooriented Programming in JAVA CS.ppt
01-introductionto Object ooriented Programming in JAVA CS.ppt01-introductionto Object ooriented Programming in JAVA CS.ppt
01-introductionto Object ooriented Programming in JAVA CS.ppt
GESISLAMIAPATTOKI
 
Oo concepts and class modeling
Oo concepts and class modelingOo concepts and class modeling
Oo concepts and class modeling
Preeti Mishra
 
CPP Object Oriented Concepts(OOPS).pptx
CPP  Object Oriented Concepts(OOPS).pptxCPP  Object Oriented Concepts(OOPS).pptx
CPP Object Oriented Concepts(OOPS).pptx
adityakumardas16
 
Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2
Julie Iskander
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
RushikeshChikane1
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
RushikeshChikane2
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka Pradhan
Priyanka Pradhan
 
Design Pattern lecture 3
Design Pattern lecture 3Design Pattern lecture 3
Design Pattern lecture 3
Julie Iskander
 
common design patterns summary.pdf
common design patterns summary.pdfcommon design patterns summary.pdf
common design patterns summary.pdf
NikolayRaychev2
 
Predictable reactive state management - ngrx
Predictable reactive state management - ngrxPredictable reactive state management - ngrx
Predictable reactive state management - ngrx
Ilia Idakiev
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
anguraju1
 
Iterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternIterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design pattern
Nitin Bhide
 
Design pattern and their application
Design pattern and their applicationDesign pattern and their application
Design pattern and their application
Hiệp Tiến
 
Marco Mancuso - Data Context Interaction
Marco Mancuso - Data Context InteractionMarco Mancuso - Data Context Interaction
Marco Mancuso - Data Context Interaction
cosenzaLab
 
Style & Design Principles 02 - Design Patterns
Style & Design Principles 02 - Design PatternsStyle & Design Principles 02 - Design Patterns
Style & Design Principles 02 - Design Patterns
Nick Pruehs
 
Design PatternsEECS 3311Song Wang[email protected]ee
Design PatternsEECS 3311Song Wang[email protected]eeDesign PatternsEECS 3311Song Wang[email protected]ee
Design PatternsEECS 3311Song Wang[email protected]ee
LinaCovington707
 
Chapter 02 The Object Model_Software E.ppt
Chapter 02 The Object Model_Software E.pptChapter 02 The Object Model_Software E.ppt
Chapter 02 The Object Model_Software E.ppt
AhammadUllah3
 
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.pptJava Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
akashsachu221
 
01-introductionto Object ooriented Programming in JAVA CS.ppt
01-introductionto Object ooriented Programming in JAVA CS.ppt01-introductionto Object ooriented Programming in JAVA CS.ppt
01-introductionto Object ooriented Programming in JAVA CS.ppt
GESISLAMIAPATTOKI
 
Ad

More from Julie Iskander (20)

HTML 5
HTML 5HTML 5
HTML 5
Julie Iskander
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
Julie Iskander
 
C for Engineers
C for EngineersC for Engineers
C for Engineers
Julie Iskander
 
Scriptaculous
ScriptaculousScriptaculous
Scriptaculous
Julie Iskander
 
Prototype Framework
Prototype FrameworkPrototype Framework
Prototype Framework
Julie Iskander
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1
Julie Iskander
 
Ajax and ASP.NET AJAX
Ajax and ASP.NET AJAXAjax and ASP.NET AJAX
Ajax and ASP.NET AJAX
Julie Iskander
 
jQuery
jQueryjQuery
jQuery
Julie Iskander
 
ASP.NET Lecture 5
ASP.NET Lecture 5ASP.NET Lecture 5
ASP.NET Lecture 5
Julie Iskander
 
ASP.NET lecture 8
ASP.NET lecture 8ASP.NET lecture 8
ASP.NET lecture 8
Julie Iskander
 
ASP.NET Lecture 7
ASP.NET Lecture 7ASP.NET Lecture 7
ASP.NET Lecture 7
Julie Iskander
 
ASP.NET Lecture 6
ASP.NET Lecture 6ASP.NET Lecture 6
ASP.NET Lecture 6
Julie Iskander
 
ASP.NET Lecture 4
ASP.NET Lecture 4ASP.NET Lecture 4
ASP.NET Lecture 4
Julie Iskander
 
ASP.NET Lecture 3
ASP.NET Lecture 3ASP.NET Lecture 3
ASP.NET Lecture 3
Julie Iskander
 
ASP.NET Lecture 2
ASP.NET Lecture 2ASP.NET Lecture 2
ASP.NET Lecture 2
Julie Iskander
 
ASP.NET Lecture 1
ASP.NET Lecture 1ASP.NET Lecture 1
ASP.NET Lecture 1
Julie Iskander
 
AJAX and JSON
AJAX and JSONAJAX and JSON
AJAX and JSON
Julie Iskander
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
Julie Iskander
 
DOM and Events
DOM and EventsDOM and Events
DOM and Events
Julie Iskander
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
Julie Iskander
 

Recently uploaded (20)

Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 

Design Pattern lecture 4

  • 1. Design Pattern By Julie Iskander MSc. Communication and Electronics
  • 2. Outlines Lecture 4 • Behavioral Design Patterns • Chain of Responsibility • Command • Mediator • Memento • Observer • State • Strategy • Template Method • Interpreter • Visitor • Iterator (Reading Assignment)
  • 4. Chain of responsibility DP • What • A replication of the business or functional process of delegating responsibility within a hierarchy. • Where • A requirement to manage tasks by coordinating objects and have them cooperate within a hierarchical structure. • Why • Avoid coupling sender of request to receiver • How • An abstract class that represents a participant or link is sub- classed into a set of links, and then the sub-classed links implement the functionality that represents their responsibility and can trigger the passing on of a requirement. The client determines the hierarchy among the links and initiates passing the requirement to the chain.
  • 10. Command DP (object - Behavioral DP)
  • 11. Command DP (object - Behavioral DP) • What • Encapsulate a request as an object, and support undoable operations. • Where • To issue requests to objects without knowing anything about the operation being requested or the receiver of the request. • Why • specify, queue, and execute requests at different times. support undo. support logging changes
  • 12. Command DP (object - Behavioral DP)
  • 13. Command DP (object - Behavioral DP)
  • 14. Command DP (object - Behavioral DP)
  • 15. Command DP (object - Behavioral DP)
  • 16. Command DP (object - Behavioral DP) • Supporting undo and redo: • Must provide a reverse method (Unexecute/Undo). • Might need to store additional state like the Receiver object, the arguments to the operation performed on the receiver, and any original values in the receiver that can change as a result of handling the request. • For one level of undo, store only the last executed command. • For multi-level undo, store a history list of executed commands.
  • 17. Mediator DP (object - Behavioral DP) • What • Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently. • Where • when many objects interconnect, to lessen the coupling • Why • To lessen the coupling between objects • How • Encapsulating collective behavior in a separate mediator object. A mediator is responsible for controlling and coordinating the interactions of a group of objects. The objects only know the mediator, thereby reducing the number of interconnections.
  • 18. Mediator DP (object - Behavioral DP)
  • 19. Mediator DP (object - Behavioral DP)
  • 20. Mediator DP (object - Behavioral DP)
  • 21. Mediator DP (object - Behavioral DP)
  • 22. Mediator DP (object - Behavioral DP)
  • 23. Mediator DP (object - Behavioral DP)
  • 24. Mediator DP (object - Behavioral DP) • Façade make requests to the subsystem, while mediator enables cooperative behaviour between colleagues objects
  • 25. MeMento DP (object - Behavioral DP) • What • capture and externalize an object's internal state so that the object can be restored to this state later. • Where • To store a snapshot of internal state of an object, to implement checkpoints • Why • To implement checkpoints, save state, undo mechanisms • How
  • 26. MeMento DP (object - Behavioral DP)
  • 27. MeMento DP (object - Behavioral DP)
  • 28. MeMento DP (object - Behavioral DP) • Memento objects are passive • Memento can be used to maintain state for undoable operations for Command DP • Used in Games to store check points
  • 29. Observer DP (object - Behavioral DP)
  • 30. Observer DP (object - Behavioral DP) • What • An Observer pattern is a design based on a one-to-many relationship, where one is a publisher that publishes an event against which many subscribers register an interest. • Where • A requirement to initiate and manage communications among a society of objects. • Why • To programmatically establish and manage a set of relationships among objects at run time. • How • Create a subject object (publisher) and any number of observer objects (subscribers), and then wire an event handler in the observer objects to an event in the subject object. In .NET, we use a delegate event-handling model to wire the observer objects to the publisher's event—delegates simplify the architecture articulated by GoF.
  • 31. Observer DP (object - Behavioral DP)
  • 32. Observer DP (object - Behavioral DP)
  • 33. Observer DP (object - Behavioral DP)
  • 34. State DP (object - Behavioral DP) • What • Allow an object to alter its behavior when its internal state changes. The object will appear to change its class. • Where • An object's behavior depends on its state, and it must change its behavior at run-time depending on that state. • Why • This lets you treat the object's state as an object in its own right that can vary independently from other objects.
  • 35. State DP (object - Behavioral DP)
  • 36. State DP (object - Behavioral DP)
  • 37. Strategy DP (object-behavioural DP) • What • A design that presents a family of algorithms or business rules encapsulated in classes that can be swapped. • Where • A requirement for the contextual implementation of different algorithms or business rules without the use of conditional code. • Why • A design that separates the choice of algorithm or business rule from its implementation and delegates the contextual choice of algorithm or business rule to client code. • How • Design an abstract strategy class that includes an abstract method from which an algorithm may be called. Prepare a context class to contain an abstract strategy class and then code the client to choose the strategy and inform the context
  • 39. Template Method DP (Class - Behavioral DP) • What • Need subclasses to house different implementations of an algorithm and defer part of the implementation to the subclass. • Where • A requirement for a common structure to house an algorithm, while vary the implementation of the algorithm. • Why • A default implementation that has the flexibility for a subclass to vary the underlying algorithm within the implementation. • How • An abstract class exposes a Template Method that wraps a set
  • 40. Template Method DP (Class - Behavioral DP)
  • 41. Template Method DP (Class - Behavioral DP)
  • 42. Template Method DP (Class - Behavioral DP) • Factory Methods are often called by template methods. (DoCreateDocument called by OpenDocument). • Template methods use inheritance to vary part of an algorithm. Strategies use delegation to vary the entire algorithm.
  • 43. Report #3: Interpreter DP Visitor DP N.B. Hand Written 
  • 44. References [1] Design Patterns, Christopher G. Lasater, Wordware Publishing, Inc. [2] http://www.CodeProject.com, How I explained OOD to my wife, Al- Farooque Shubho [3]http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod,PrinciplesOf Ood [4]http://www.CodeProject.comHow I explained Design Patterns to my wife: Part 1,By Al-FarooqueShubho [5] http://www.shubho.net/2010/09/interface-vs-abstract-class-classic.html, Al-FarooqueShubho [6]C# 3.0 Design Patterns, Judith Bishop [7]Head First Design Pattern, Eric Freeman, Elisabeth Freeman, Kathy Sierra, Bert Bates [8] Pro .NET 2.0 Code and Design Standards in C#, Mark Horner
  • 45. The End Thank you and Good Luck

Editor's Notes

  • #6: A group of classes each have processes to run in turn, but there is no way to directly determine in which class order each should runits process
  • #12: Allows a request to an object to exist as an objectUsed for doing and undoing and storing a request queue for an objectExample: A document object needs a way to add and store undo and redo actions
  • #19: Allows group of objects to communicate in a disassociated manner and encapsulates this communication while keeping the objects loosely coupled.
  • #26: Capture an object’s internal state without violating encapsulation of the object, and preserve that state for some purpose.
  • #27: Originator class whose internal state to captureMemento  class in which we store the originator’s stateCaretaker  stores the memento until needed to restore the state or originator