GRASP: More Patterns for Assigning Responsibilities Presented By Dr. Shazzad Hosain.

Slides:



Advertisements
Similar presentations
Object-Oriented Analysis and Design CHAPTER 17, 25: GRASP PATTERNS 1.
Advertisements

SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
GRASP The other four What are the first five? What is the goal/purpose of using patterns?
GRASP Patterns M Taimoor Khan
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Object-Oriented Software Engineering Practical Software Development using UML and Java Design Patterns – Part 2 Sources: Chapter 6: Using Design Patterns,
Chapter 25 GRASP: More Objects with Responsibilities 1CS6359 Fall 2011 John Cole.
NJIT More GRASP Patterns Chapter 22 Applying UML and Patterns Craig Larman Prepared By: Krishnendu Banerjee.
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.
Chapter 25 More Design Patterns. Polymorphism Issue: Conditional variation –If-then-else or switch statements –New variation or case: Conditional statements.
Fall 2009ACS-3913 R. McFadyen1 Polymorphism Indirection Pure Fabrication Protected Variations (Law of Demeter) More GRASP Patterns.
GRASP : Designing Objects with Responsibilities
March 6, R. McFadyen1 Pure Fabrication P Problem: You have a responsibility to assign to a class, but assigning it to a class in the.
October 20, 2005Architectural Design, ECEN Architectural Design Architecture Business Cycle Design for Maintainability ECEN 5543 / CSCI 5548 SW Eng.
March R. McFadyen1 Pure Fabrication P Problem: You have a responsibility to assign to a class, but assigning it to a class in the conceptual.
Chapter 26 Applying Gang of Four Design Patterns 1CS6359 Fall 2012 John Cole.
Chapter 25 More Design Patterns.
Larman, chapters 25 and 26 CSE432 Object-Oriented Software Engineering Glenn D. Blank, Lehigh University Pure Fabrication and “Gang of Four” Design Patterns.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
GRASP Principles. How to Design Objects The hard step: moving from analysis to design How to do it? –Design principles (Larman: “patterns”) – an attempt.
GRASP Patterns Presented By Dr. Shazzad Hosain. Patterns A pattern describes a problem and solution, and given a name. Examples are Singleton, Adapter,
Chapter 17. GRASP General Responsibility Assignment Software Patterns (Principles) OOD: after identifying requirements, create domain model, define responsiblities.
1 Chapter 17 GRASP Design Patterns: Designing Objects with Responsibilities.
1 SAD2 - UML 4 th Lecture Class Diagram in Construction Phase Patterns Case Study Lecturer: Dr Dimitrios Makris
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Chapter 17. Initial Object Design Inputs: requirements meetings various Use Cases – 10% complete Key risks addressed with preliminary programming System.
CS 325: Software Engineering February 12, 2015 Applying Responsibility-Assignment Patterns Design Patterns Situation-Specific Patterns Responsibility-Assignment.
GRASP: Designing Objects With Responsibilities
Object-Oriented Analysis and Design Mar 11, 2008.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
TK2023 Object-Oriented Software Engineering CHAPTER 3 CASE STUDY: POS SYSTEM.
Chapter 17 GRASP: Designing Objects with Responsibilities. 1CS6359 Fall 2011 John Cole.
Design Patterns. Patterns “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
Copyright © Craig Larman All Rights Reserved Responsibility-Driven Design with the GRASP Patterns.
Pure Fabrication and “Gang of Four” Design Patterns
Next Gen POS Example GRASP again. Same Patterns Different Example!
CSSE 374: More GRASP’ing for Object Responsibilities
Designing a Persistence Framework With Patterns
GRASP: Designing Objects with Responsibilities
IntellAgile Copyright © 2002 Craig Larman. All rights reserved. Object Design and Use- Case Realizations with GRASP Patterns.
What to remember from Chap 13 (Logical architecture)
OO Methodology Elaboration Iteration 2 - Design Patterns -
Patterns Roberto Damiani Mendes. Roteiro Definition; Definition; Architecture Patterns; Architecture Patterns; Design Patterns; Design Patterns; GRASP.
GRASP Patterns Best Practices for Object-Oriented Software Design.
Elaboration Iteration 3 – Part 3 - Persistence Framework -
Copyright © Craig Larman All Rights Reserved COMP-350 Object-Oriented Analysis and Design GRASP: Designing Objects with Responsibilities Reference:
Chapter 17 Designing with Responsibilities. Fig
References: Applying UML and patterns Craig Larman
Object-Oriented Analysis and Design Week 12, 2009.
General Principles in Assigning Responsibilities Responsibilities Responsibility-Driven Design CRC Cards GRASP.
GRASP.
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,
GRASP – Designing Objects with Responsibilities
GoF Patterns (GoF) popo.
Conception OBJET GRASP Patterns
TK2023 Object-Oriented Software Engineering
Apply Expert, Creator, Controller, Low Coupling, High Cohesion
GRASP : Designing Objects with Responsibilities
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 2005 Instructor: Patrice Chalin.
Chapter 25 GRASP The other four.
GoF Design Patterns (Ch. 26)
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Chapter 25 GRASP The other four.
GRASP.
Next Gen POS Example GRASP again.
GoF Patterns Ch. 26.
Presentation transcript:

GRASP: More Patterns for Assigning Responsibilities Presented By Dr. Shazzad Hosain

GRASP Patterns Previously we have explored Information Expert Creator High Cohesion Low Coupling and Controller The other four GRASP patterns are Polymorphism Indirection Pure Fabrication and Protected Variations

Polymorphism Example: Let’s say you like to sale NextGen POS system to different countries. You need to integrate different external third- party tax calculators such as TaxMasterAdapter GoodAsGoldTaxProAdapter etc. If (Country == “US”) Use TaxMasterAdapter Else if (Country == “UK”) Use GoodAsGoldTaxProAdapter Else if …. End If

Polymorphism

UML Notation

Polymorphism Context/Problem: How to handle alternatives based on type? How to create pluggable software components? Solution: If alternatives or behaviors vary by type (class), then assign responsibility for the behavior – using polymorphic operations – to the types for which the behavior varies. Corollary: Do not test for the type of an object and use conditional logic to perform varying alternatives based on type.

Pure Fabrication Example: Suppose we need to save Sale object in a relational DB. Information Expert or Expert says Sale should do it, because Sale knows its total. But it violates Low Coupling and High Cohesion because Sale will be coupled with JDBC etc. This class is a Pure Fabrication – a figment of the imagination

Benefits of Pure Fabrication Sale remains well-designed, with high cohesion and low coupling The PersistentStorage class is itself relatively cohesive, having the sole purpose of storing or inserting objects in a persistent storage medium The PersistentStorage class is very generic and reusable object This class is a Pure Fabrication – a figment of the imagination Domain Class ?

Pure Fabrication Context/Problem: What object should have the responsibility, when you do not want to violate High Cohesion and Low Coupling, or other goals, but solutions offered by Expert (for example) are not appropriate? Solution: Assign a highly cohesive set of responsibilities to an artificial or convenience class that does not represent a problem domain concept – something made up, to support high cohesion, low coupling, and reuse. Finally, a pure fabrication implies making something up, which we do when we’re desperate!

Indirection Example of Indirectoin PersistentStorage Class is also an indirection. Act as an intermediary between the Sale and the database.

Indirection Context/Problem: Where to assign responsibility, to avoid direct coupling between two (or more) things? How to decouple objects so that low coupling is supported and reuse remains high? Solution: Create an intermediate object to mediate between other components or services so that they are not directly coupled. The intermediary creates and indirection between the other components.

Protected Variations Context/Problem: How to design objects, subsystems and systems so that the variations or instability in these elements does not have an undesirable impact on other elements? Solution: Identify points of predicted variation or instability; assign responsibilities to create a stable interface around them. Example: Prior external tax calculator is also a protected variation example.

References Chapter 22 of “Applying UML and Patterns – An Introduction to Object-Oriented Analysis and Design and the Unified Process” – by Craig Larman