SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin
Agenda – Lecture 12a … 9/17/2018 SOEN 343, © P.Chalin,
Gang Of Four Gamma, Helm, Johnson, Vlissides Some patterns covered in Larman, Chap. 23,… All patterns in XDE As documentation. As dynamic templates. Erich 9/17/2018 SOEN 343, © P.Chalin,
GoF Pattern Summary (& Relationhips) [Picutre (c) GoF CD] 9/17/2018 SOEN 343, © P.Chalin,
GoF Pattern Classification Behavioral Patterns Creational Patterns Structural Patterns 9/17/2018 SOEN 343, © P.Chalin,
GoF Behavioral Patterns Chain of Responsibility Command Interpreter Iterator Mediator Memento Observer State Strategy Template Method Visitor 9/17/2018 SOEN 343, © P.Chalin,
GoF Creational Patterns Abstract Factory Builder Factory Method (we saw Simple Factory) Prototype Singleton 9/17/2018 SOEN 343, © P.Chalin,
GoF Structural Patterns Adapter Bridge Composite Decorator Facade Flyweight Proxy 9/17/2018 SOEN 343, © P.Chalin,
Facade 9/17/2018 SOEN 343, © P.Chalin,
Facade 9/17/2018 SOEN 343, © P.Chalin,
Singleton (Larman Section 23.4) XDE Patterns Singleton - uniqueInstance : Singleton - attribute # Singleton( ) + getUniqueInstance ( ) : Singleton + getAttr( ) 9/17/2018 SOEN 343, © P.Chalin,
Strategy Context / problem: How to design for varying, but related, algorithms or policies? How to design for the ability to change (even dynamically) these algorithms or policies? Solution: Define each algorithm/policy/strategy in a separate class with a common interface 9/17/2018 SOEN 343, © P.Chalin,
Strategy 9/17/2018 SOEN 343, © P.Chalin,
How Do We Create a Strategy? 9/17/2018 SOEN 343, © P.Chalin,
Composite Larman 23.7 (but explanation intertwined with other pattern) Context / problem: How to treat an aggregate structure of objects the same way as an atomic (non-aggregate) object? Solution: Define classes for composite and atomic objects that implement the same interface. 9/17/2018 SOEN 343, © P.Chalin,
Observer Pattern 9/17/2018 SOEN 343, © P.Chalin,
Observer How shall we have the display be updated? Why not … have the Sale inform the display when it changes value. 9/17/2018 SOEN 343, © P.Chalin,
What is Wrong With This? 9/17/2018 SOEN 343, © P.Chalin,
Observer Pattern Context / Problem: Different kinds of subscriber objects are interested in the state changes or events of a publisher object, and want to react in their own way when the publisher generates the event. … 9/17/2018 SOEN 343, © P.Chalin,
Observer Pattern Solution: Define a “subscriber” or “listener” interface. Subscribers implement this interface. The publisher can dynamically register subscribers who are interested in an event, and notify them when an event occurs. Clarification: Publisher can dynamically process registration requests from subscribers. 9/17/2018 SOEN 343, © P.Chalin,
Observers: Illustration Change requests go down – e.g. one cell in the spread sheet might be changed. Notifications go up (upward dependencies are not ok) 9/17/2018 SOEN 343, © P.Chalin,
Observer Class Diagram (Shown in class) 9/17/2018 SOEN 343, © P.Chalin,
Sale Example 9/17/2018 SOEN 343, © P.Chalin,
Observer Pattern (GoF book) 9/17/2018 SOEN 343, © P.Chalin,