SWE 316: Software Design and Architecture Objectives Lecture # 15 Behavioral Design Patterns SWE 316: Software Design and Architecture  To learn the behavioral.

Slides:



Advertisements
Similar presentations
Design Patterns.
Advertisements

Chapter 6 Introduction to Design Patterns. Sample Design Goals and Ways to Accomplish Them Reusability, Flexibility, and Efficiency o Reuse flexible designs.
Welcome to. Who am I? A better way to code Design Patterns ???  What are design patterns?  How many are there?  How do I use them?  When do I use.
Behavioral Design Patterns May 5, 2015May 5, 2015May 5, 2015.
Observer Method 1. References Gamma Erich, Helm Richard, “Design Patterns: Elements of Reusable Object- Oriented Software” 2.
CS590L - Lecture 6 1 CS590L Distributed Component Architecture References: - E. Gamma, R. Helm, R. Johnson, J. Vlissides, Design Patterns: Elements of.
GoF Sections 2.7 – 2.9 More Fun with Lexi. Lexi Document Editor Lexi tasks discussed:  Document structure  Formatting  Embellishing the user interface.
Iterators T.J. Niglio Computer & Systems Engineering Fall 2003 Software Design & Documentation Object Behavioral.
Design Patterns CS is not simply about programming
Chapter 9 Behavioral Design Patterns. Process Phase Affected by This Chapter Requirements Analysis Design Implementation ArchitectureFrameworkDetailed.
Patterns Design 13 February.
Algorithm Programming Behavioral Design Patterns Bar-Ilan University תשס " ו by Moshe Fresko.
GoF Sections 2.7 – 2.9 More Fun with Lexi. Lexi Document Editor Lexi tasks discussed:  Document structure  Formatting  Embellishing the user interface.
5. DESIGN I: SOFTWARE ARCHITECTURE. Plan project Integrate & test system Analyze requirements Design Maintain Test unitsImplement Software Engineering.
Behavioral Patterns C h a p t e r 5 – P a g e 128 BehavioralPatterns Design patterns that identify and realize common interactions between objects Chain.
Programming With Java ICS201 University Of Hail1 Chapter 12 UML and Patterns.
The Design Discipline.
BDP Behavioral Pattern. BDP-2 Behavioral Patters Concerned with algorithms & assignment of responsibilities Patterns of Communication between Objects.
Java Programming: Advanced Topics 1 Collections and Wealth of Utilities.
Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed.
Prologue: The Software Process. Main Phases of Software Process 1. Requirements Analysis (answers “WHAT?”) Specifying what the application must do 2.
Chapter 5 Design Principles II: Flexibility, Reusability, and Efficiency.
Lecture # 06 Design Principles II
Chapter 5 Design Principles II: Flexibility, Reusability, and Efficiency.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
CSE 332: Design Patterns (Part I) Introduction to Design Patterns Design patterns were mentioned several times so far –And the Singleton Pattern was discussed.
26 February Humpty Dumpty Presentations Software Architecture (cont)
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 09. Review Introduction to architectural styles Distributed architectures – Client Server Architecture – Multi-tier.
Chapter 9 Behavioral Design Patterns o Interpreter o Iterator o Mediator o Observer o State o Chain of Responsibility o Command o Template.
System Models, Patterns and Software Architectures 14 February.
Behavioral Design Patterns October 19, 2015October 19, 2015October 19, 2015.
Behavioral Design Patterns Morteza Yousefi University Of Science & Technology Of Mazandaran 1of 27Behavioral Design Patterns.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
Lexi case study (Part 2) Presentation by Matt Deckard.
SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03.
ECE450S – Software Engineering II
Chapter 6 Introduction to Design Patterns. Process Phase Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFrameworkDetailed.
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
CS 4233 Review Feb February Review2 Outline  Previous Business – My.wpi.edu contains all grades to date for course – Review and contact.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 13 Creational Design Pattern SWE 316: Software Design and Architecture.
Chapter 8 Structural Design Patterns
Behavioural Design Patterns Quote du jour: ECE450S – Software Engineering II I have not failed. I've just found 10,000 ways that won't work. - Thomas Edison.
DESIGN PATTERNS -BEHAVIORAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
CS 210 Final Review November 28, CS 210 Adapter Pattern.
Behavioral Patterns1 Nour El Kadri SEG 3202 Software Design and Architecture Notes based on U of T Design Patterns class.
Design Reuse Earlier we have covered the re-usable Architectural Styles as design patterns for High-Level Design. At mid-level and low-level, design patterns.
Using Software Design Patterns Bill Anderson. About me Fox developer since 1987 Fox developer since 1987 Program Director, Los Angeles Visual Foxpro Developers.
BEHAVIORAL PATTERNS 13-Sep-2012 Presenters Sanjeeb Kumar Nanda & Shankar Gogada.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern.
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
CS212: Object Oriented Analysis and Design Lecture 39: Design Pattern-III.
Interface Patterns. Adapter Provides the interface a client expects, using the services of a class with a different interface Note Avoid using object.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another using Arrays. How does one work with these.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
CSE 332: Design Patterns (Part II) Last Time: Part I, Familiar Design Patterns We’ve looked at patterns related to course material –Singleton: share a.
Design Patterns Behavioral Patterns. Chain of Responsibility Avoid coupling the sender of a request to its receiver by giving more than one object a chance.
Overview of Behavioral Patterns ©SoftMoore ConsultingSlide 1.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Chapter 10 Design Patterns.
Introduction to Design Patterns
Behavioral Design Patterns
Design Patterns in Game Design
Chapter 9 Behavioral Design Patterns
Object Oriented Design Patterns - Behavioral Patterns
Software Design Lecture : 39.
Presentation transcript:

SWE 316: Software Design and Architecture Objectives Lecture # 15 Behavioral Design Patterns SWE 316: Software Design and Architecture  To learn the behavioral design patterns and when to use them. Ch 9 Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

SWE 316: Software Design and Architecture Patterns  Behavioral Design Patterns capture behavior among objects  Interpreter  Iterator  Mediator  Observer  State  Chain of Responsibility  Command  Template InterpreterIteratorMediatorObserverStateChain of Responsibility 2/22

SWE 316: Software Design and Architecture Interpreter Design Pattern  Design Purpose  Interpret expressions written in a formal grammar.  Design Pattern Summary  Represent the grammar using a Recursive design pattern form: Pass interpretation to aggregated objects. Interpreter IteratorMediatorObserverStateChain of Responsibility 3/22

SWE 316: Software Design and Architecture AbstractExpression interpret() Client TerminalExpression interpret() NonTerminalExpression interpret() 1..n Interpreter Design Pattern -- a form for parsing and a means of processing expressions. KEY CONCEPT Design Goal At Work: Flexibility, Correctness, Reuse Interpreter IteratorMediatorObserverStateChain of Responsibility 4/22

SWE 316: Software Design and Architecture Purpose of Iterator  given a collection of objects e.g.,  the videos in a video store  a directory  having specified ways to progress through them e.g.,  “list in alphabetical order”  “list all videos currently on loan” ... encapsulate each of these ways Aggregate object iterator2 iterator7 Interpreter Iterator MediatorObserverStateChain of Responsibility 5/22

SWE 316: Software Design and Architecture Iterator Design Pattern  Design Purpose  Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.  Design Pattern Summary  Encapsulate the iteration in a class pointing (in effect) to an element of the aggregate. Interpreter Iterator MediatorObserverStateChain of Responsibility 6/22

SWE 316: Software Design and Architecture /* To perform desiredOperation() on elements of the aggregate according to the iteration (order) i : */ for( i.setToFirst(); !i.isDone(); i.increment() ) desiredOperation( i.getCurrentElement() ); Using Iterator Functions Interpreter Iterator MediatorObserverStateChain of Responsibility 7/22

SWE 316: Software Design and Architecture // Iterator "points" to first element: void setToFirst(); // true if iterator "points" past the last element: boolean isDone(); // Causes the iterator to point to its next element: void increment(); // Return the element pointed to by the iterator: C getCurrentElement(); Functions for Iterator Interpreter Iterator MediatorObserverStateChain of Responsibility 8/22

SWE 316: Software Design and Architecture Iterator in Arrays, Vector, and in General Iterator Operations Set to beginning Increment Get current element Check not done yet The Iterator Index (integer) i on array myArray i = 0++imyArray[ i ] i < myArray.length Index (integer) j on Vector myVector j = 0++j myVector.get( j ) j < myVector.size() Iterator (object) myIterator.setToFirst() myIterator.increment() myIterator.getCurrent Element() ! myIterator.isDone() Interpreter Iterator MediatorObserverStateChain of Responsibility 9/22

SWE 316: Software Design and Architecture iterator: Iterator element: Element Aggregate of Element objects Key: Intended sequence of Element objects After first() executes, iterator references this object. After increment() executes, iterator references this object. Before increment() executes, iterator references this object. Imagining Iterator Interpreter Iterator MediatorObserverStateChain of Responsibility 10/22

SWE 316: Software Design and Architecture Mediator  Design Purpose  Avoid references between dependent objects.  Design Pattern Summary  Capture mutual behavior in a separate class. InterpreterIterator Mediator ObserverStateChain of Responsibility 11/22

SWE 316: Software Design and Architecture Solicitation of Customer Information 1 of 2 Name and Location Basic information InterpreterIterator Mediator ObserverStateChain of Responsibility 12/22

SWE 316: Software Design and Architecture Solicitation of Customer Information 2 of 2 Account Information Additional information Customer ID Total business Amount due InterpreterIterator Mediator ObserverStateChain of Responsibility 13/22

SWE 316: Software Design and Architecture MediatorColleague ConcreteMediator ConcreteColleague1ConcreteColleague2 The Mediator Class Model InterpreterIterator Mediator ObserverStateChain of Responsibility 14/22

SWE 316: Software Design and Architecture Observer Design Pattern  Design Purpose  Arrange for a set of objects to be affected by a single object.  to keep a set of objects up to date with the state of a designated object  Design Pattern Summary  The single object aggregates the set, calling a method with a fixed name on each member. InterpreterIteratorMediator Observer StateChain of Responsibility 15/22

SWE 316: Software Design and Architecture Source notify() Observer update() for all Observer’s o: o.update(); Client of this system n Server partClient part Observer Design Pattern InterpreterIteratorMediator Observer StateChain of Responsibility 16/22

SWE 316: Software Design and Architecture Source notify() Observer update() ConcreteSource state ConcreteObserver observerState update() for all Observer’s o: o.update(); Client n Server partClient part 1 Observer Design Pattern InterpreterIteratorMediator Observer StateChain of Responsibility 17/22

SWE 316: Software Design and Architecture State Design Pattern  Design Purpose  Cause an object to behave in a manner determined by its state.  Design Pattern Summary  Aggregate a State object and delegate behavior to it. InterpreterIteratorMediatorObserver State Chain of Responsibility 18/22

SWE 316: Software Design and Architecture TargetStateB handleRequest() Target doRequest() doRequest() behaves according to state of Target targetState TargetState handleRequest() Client TargetStateA handleRequest() 1 { targetState.handleRequest(); }... State Design Pattern Structure InterpreterIteratorMediatorObserver State Chain of Responsibility 19/22

SWE 316: Software Design and Architecture Chain of Responsibility Design Pattern  Design Purpose  Allow a set of objects to service a request. Present clients with a simple interface.  to distribute functional responsibility among a collection of objects.  Design Pattern Summary  Link the objects in a chain via aggregation, allowing each to perform some of the responsibility, passing the request along. InterpreterIteratorMediatorObserverState Chain of Responsibility 20/22

SWE 316: Software Design and Architecture Other Patterns  Command  Template  Will not be covered InterpreterIteratorMediatorObserverStateChain of Responsibility 21/22

SWE 316: Software Design and Architecture Summary of Behavioral Patterns Behavioral Design Patterns capture behavior among objects  Interpreter handles expressions in grammers  Iterator visits members of a collection  Mediator captures behavior among peer objects  Observer updates objects affected by a single object  State allows method behavior to depend on current status  Chain of Responsibility allows a set of objects to provide functionality collectively  Command captures function flexibly (e.g. undo-able)  Template captures basic algorithms, allowing variability InterpreterIteratorMediatorObserverStateChain of Responsibility 22/22