SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.

Slides:



Advertisements
Similar presentations
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.
Advertisements

18-1 Verifying Object Behavior and Collaboration Role playing – the act of simulating object behavior and collaboration by acting out an object’s behaviors.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
(c) 2009 University of California, Irvine – André van der Hoek1June 13, 2015 – 21:42:16 Informatics 122 Software Design II Lecture 8 André van der Hoek.
Design Patterns CS is not simply about programming
NJIT More GRASP Patterns Chapter 22 Applying UML and Patterns Craig Larman Prepared By: Krishnendu Banerjee.
Design Patterns. What are design patterns? A general reusable solution to a commonly occurring problem. A description or template for how to solve a problem.
Fall 2009ACS-3913 Ron McFadyen1 idea was first put forth by Christopher Alexander (1977) in his work on architectural design principles a pattern is a.
March R McFadyen1 GoF (Gang of Four): Gamma, Johnson, Helm & Vlissides Book: Design Patterns: Elements of Reusable Object-Oriented Software.
Chapter 26 Applying Gang of Four Design Patterns 1CS6359 Fall 2012 John Cole.
Design Patterns Alan Shalloway, James Trott, Design Patterns Explained, Addison-Wesley, Gamma, Helm, Johnson, Vlissides, Design Patterns, Elements.
樣式導向設計 (Pattern-Oriented Design) 課程簡介 Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering.
Patterns 1 Patterns in OO - history 77 - Work of the architect Christopher Alexander 80s - Kent Beck playing with Smalltalk 91 - Gamma’s PhD thesis on.
CSSE 374: Introduction to Gang of Four Design Patterns
CSSE 374: 3½ Gang of Four Design Patterns These slides derived from Steve Chenoweth, Shawn Bohner, Curt Clifton, and others involved in delivering 374.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
GoF Design Patterns (Ch. 26). GoF Design Patterns Adapter Factory Singleton Strategy Composite Façade Observer (Publish-Subscribe)
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
Introduction to Design Patterns. Questions What is a design pattern? Who needs design patterns? How different are classes and objects in APL compared.
Creational Patterns
Programmeerimine Delphi keskkonnas MTAT Programmeerimine Delphi keskkonnas MTAT Jelena Zaitseva
OO Methodology Elaboration Iteration 2 - Design Patterns -
Gang of Four Patterns 23 total 15 useful How are they different from GRASP Patterns?
Design Patterns. 1 Paradigm4 Concepts 9 Principles23 Patterns.
GRASP: More Patterns for Assigning Responsibilities Presented By Dr. Shazzad Hosain.
Five Minute Design Patterns Doug Marttila Forest and the Trees May 30, 2009 Template Factory Singleton Iterator Adapter Façade Observer Command Strategy.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Elaboration: Iteration 2. Elaboration: Iteration 2 Basics Iteration 1 ends with : All the software has been tested: The idea in the UP is to do early,
The Object-Oriented Thought Process Chapter 15
Chapter 10 Design Patterns.
Presentation on GoF Design Patterns Submitted by WWW. ASSIGNMENTPOINT
樣式導向設計 (Pattern-Oriented Design) 課程簡介
Chapter 5:Design Patterns
GoF Patterns (GoF) popo.
MPCS – Advanced java Programming
Design Patterns Lecture part 2.
Conception OBJET GRASP Patterns
Introduction to Design Patterns
Design Patterns with C# (and Food!)
object oriented Principles of software design
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
GoF Design Patterns (Ch. 26). GoF Design Patterns Adapter Factory Singleton Strategy Composite Façade Observer (Publish-Subscribe)
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
GoF Design Patterns (Ch. 26)
Informatics 122 Software Design II
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
CSE 403 Software Design.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
DESIGN PATTERNS : Introduction
GoF Design Patterns (Ch. 26)
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Informatics 122 Software Design II
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
GoF Patterns Ch. 26.
Presentation transcript:

SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin

Agenda – Lecture 12a Review & renew. GRASP: protected variations. GoF: Adapter Façade Factory Strategy Observer 2/28/2019 SOEN 343, © P.Chalin,

GRASP Information Expert. Creator. High Cohesion. Low Coupling. Controller. Polymorphism. Pure Fabrication. Indirection. Protected Variations. 2/28/2019 SOEN 343, © P.Chalin,

GRASP Protected Variations Problem: How to design objects, subsystems, and systems so that the variations or instability in these elements does not have an undesireable impact on other elements? Solution: Identify points of predicted variation or instability; assign responsibility to create a stable interface around them. 2/28/2019 SOEN 343, © P.Chalin,

Core PV Mechanisms Encapsulation. Interfaces. Polymorphism. Indirection, … (Note: we are speaking of mechanisms, not principles) 2/28/2019 SOEN 343, © P.Chalin,

PV: Pick Your Battles Beware not to try to overly “future-proof” your designs. Actually, this is true of any principle … 2/28/2019 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 2/28/2019 SOEN 343, © P.Chalin,

GoF Pattern Summary (& Relationhips) [Picutre (c) GoF CD] 2/28/2019 SOEN 343, © P.Chalin,

GoF Pattern Classification Behavioral Patterns Creational Patterns Structural Patterns 2/28/2019 SOEN 343, © P.Chalin,

GoF Behavioral Patterns Chain of Responsibility Command Interpreter Iterator Mediator Memento Observer State Strategy Template Method Visitor 2/28/2019 SOEN 343, © P.Chalin,

GoF Creational Patterns Abstract Factory Builder Factory Method Prototype Singleton 2/28/2019 SOEN 343, © P.Chalin,

GoF Structural Patterns Adapter Bridge Composite Decorator Facade Flyweight Proxy 2/28/2019 SOEN 343, © P.Chalin,

Adapter Context / problem How to resolve incompatible interfaces, or provide a stable interface to similar components with different interfaces? Solution: Convert the original interface of a component into another interface, through an intermediate adapter object. 2/28/2019 SOEN 343, © P.Chalin,

Adapter Suppose we have a tax calculation class (or external library) but the interface is not well suited for our application. 2/28/2019 SOEN 343, © P.Chalin,

Adapter Adapter provides an interface suited to the application GoodAsGoldTaxProAdapter getTaxes( Sale ) : List of TaxLineItems computeTax(…):double GoodAsGoldTaxPro Adapter provides an interface suited to the application 2/28/2019 SOEN 343, © P.Chalin,

Adapter (For More than One Class) What if more than one class (library) needs to be adapted? 2/28/2019 SOEN 343, © P.Chalin,

Adapter 2/28/2019 SOEN 343, © P.Chalin,

Facade 2/28/2019 SOEN 343, © P.Chalin,

Facade 2/28/2019 SOEN 343, © P.Chalin,

Factory Context / problem: Who should be responsible for creating objects when there are special considerations, such as complex creation logic, a desire to separate the creation responsibilities for better cohesion, and so forth? Solution: Create a Pure Fabrication object called a Factory. 2/28/2019 SOEN 343, © P.Chalin,

Factory Example SOEN 343, © P.Chalin, Have we seen code like this anywhere? 2/28/2019 SOEN 343, © P.Chalin,

Larman’s comment on prev. figure Note that the factory methods return objects types to an interfacre rather than a class so that the factory can return any implementation of the interface. Factory methods can also 2/28/2019 SOEN 343, © P.Chalin,

(Abstract) Factory Example (GoF) 2/28/2019 SOEN 343, © P.Chalin,

FrontControllerServlet RemoveStudentCommand Factory (in EAs) FrontControllerServlet FrontCommand # processRequest ( ) + init ( ) - getCommand ( ) : FrontCommand + processRequest ( ) - getCommandClass ( ) RemoveStudentCommand ViewStudInfoCommand + processRequest ( ) + processRequest ( ) 2/28/2019 SOEN 343, © P.Chalin,

Singleton (Larman Section 23.4) XDE Patterns Singleton - uniqueInstance : Singleton - attribute # Singleton( ) + getUniqueInstance ( ) : Singleton + getAttr( ) 2/28/2019 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 2/28/2019 SOEN 343, © P.Chalin,

Strategy 2/28/2019 SOEN 343, © P.Chalin,

How Do We Create a Strategy? 2/28/2019 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. 2/28/2019 SOEN 343, © P.Chalin,

Observer Pattern 2/28/2019 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. 2/28/2019 SOEN 343, © P.Chalin,

What is Wrong With This? 2/28/2019 SOEN 343, © P.Chalin,

Presentation Domain Data Source Layers: Dependencies Dependencies 2/28/2019 SOEN 343, © P.Chalin,

Layers: Functionality Presentation Domain Functionality / services Data Source 2/28/2019 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. … 2/28/2019 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. 2/28/2019 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) 2/28/2019 SOEN 343, © P.Chalin,

Observer Class Diagram (Shown in class) 2/28/2019 SOEN 343, © P.Chalin,

Sale Example 2/28/2019 SOEN 343, © P.Chalin,

Observer Pattern (GoF book) 2/28/2019 SOEN 343, © P.Chalin,