COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler

Slides:



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

GRASP The other four What are the first five? What is the goal/purpose of using patterns?
GRASP Patterns M Taimoor Khan
Oct 2, Ron McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m Function:
Copyright W. Howden1 Lecture 6: Design Evaluation and Intro to OO Design Patterns.
Chapter 25 GRASP: More Objects with Responsibilities 1CS6359 Fall 2011 John Cole.
© 2005 Prentice Hall8-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
NJIT More GRASP Patterns Chapter 22 Applying UML and Patterns Craig Larman Prepared By: Krishnendu Banerjee.
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
October 20, 2005Architectural Design, ECEN Architectural Design Architecture Business Cycle Design for Maintainability ECEN 5543 / CSCI 5548 SW Eng.
Feb 4, Ron McFadyen1 founded on principles of good OO design idea was first put forth by Christopher Alexander (1977) in their work concerning.
Chapter 26 Applying Gang of Four Design Patterns 1CS6359 Fall 2012 John Cole.
Chapter 25 More Design Patterns.
GRASP Design Patterns: Designing Objects with Responsibilities
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
GRASP Pattern Zhen Jiang West Chester University
GRASP Principles. How to Design Objects The hard step: moving from analysis to design How to do it? –Design principles (Larman: “patterns”) – an attempt.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
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.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Architecture GRASP Realization of use cases in interaction diagrams Design class diagram Design ( how )
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
Chapter 17. Initial Object Design Inputs: requirements meetings various Use Cases – 10% complete Key risks addressed with preliminary programming System.
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
GoF Design Patterns (Ch. 26). GoF Design Patterns Adapter Factory Singleton Strategy Composite Façade Observer (Publish-Subscribe)
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.
CS212: Object Oriented Analysis and Design GRASP Design Principles.
Copyright © Craig Larman All Rights Reserved Responsibility-Driven Design with the GRASP Patterns.
CSSE 374: More GRASP’ing for Object Responsibilities
GRASP: Designing Objects with Responsibilities
IntellAgile Copyright © 2002 Craig Larman. All rights reserved. Object Design and Use- Case Realizations with GRASP Patterns.
OO Methodology Elaboration Iteration 2 - Design Patterns -
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Patterns Roberto Damiani Mendes. Roteiro Definition; Definition; Architecture Patterns; Architecture Patterns; Design Patterns; Design Patterns; GRASP.
OO Design Roshan Chitrakar. Analysis to Design Do the RIGHT thing Do the RIGHT thing Requirement Analysis Requirement Analysis Domain Modeling with addition.
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
Design. 2 The Need for Software Blueprints Knowing an object-oriented language and having access to a library is necessary but not sufficient in order.
GRASP: More Patterns for Assigning Responsibilities Presented By Dr. Shazzad Hosain.
Basic Characteristics of Object-Oriented Systems
General Principles in Assigning Responsibilities Responsibilities Responsibility-Driven Design CRC Cards GRASP.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
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
Conception OBJET GRASP Patterns
TK2023 Object-Oriented Software Engineering
Apply Expert, Creator, Controller, Low Coupling, High Cohesion
The Object Oriented Approach to Design
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
GRASP : Designing Objects with Responsibilities
GoF Design Patterns (Ch. 26). GoF Design Patterns Adapter Factory Singleton Strategy Composite Façade Observer (Publish-Subscribe)
GRASP Design Patterns: Designing Objects with Responsibilities
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.
GoF Patterns Ch. 26.
Presentation transcript:

COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler

The 9 GRASP Principles 1.Expert 2.Creator 3.Controller 4.Low Coupling 5.High Cohesion 6.Polymorphism 7.Pure Fabrication 8.Indirection 9.Protected Variations

Principle: Information Expert Assign a responsibility to the object that has the information necessary to fulfill it. “That which has the information, does the work.” Eg, Which object knows whether a user has permission to access a given document?

Principle: Creator What object creates an X? Choose an object C, such that: –C contains or aggregates X –C closely uses X –C has the initializing data for X The more, the better. Eg, Which object creates a session, user, project, document?

Principle: Creator What object creates a Command?

Principle: Controller What object in the domain (or application coordination layer) receives requests for work from the UI layer? Solution: Choose a class whose name suggests: –The overall “system”, device, or subsystem A kind of Façade class –Or, represents the use case scenario or session

Principle: Controller Eg, What object receives a request to logon and begin a session? Eg, What object receives the request to perform a command? Guideline: Normally, a controller should delegate to other objects the work that needs to be done; it coordinates or controls the activity. It does not do much work itself.

Principle: Polymorphism How to handle alternatives based on type … How to create pluggable software components … Assign responsibility for the behaviour to a polymorphic operation in the superclass-subclass hierarchy. Clearly generalization and polymorphism handles the situation where behaviour varies by type. To create pluggable components adopt a client-server relationship, then vary server using polymorphism: each server subclass is a pluggable component.

Principle: Polymorphism Implies that your code should never have switch’s or conditional logic that tests the type of an object! Eg, in CUWME where is polymorphism used? Command class Composite pattern: Document class Role: is using RBAC1 …

Principle: Pure Fabrication When assigning responsibilities to an existing object would violate cohesion or coupling or … 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. Pure – because it is a clean design (high cohesion, low coupling) Fabrication – because it is made up, invented, imagined

Principle: Pure Fabrication Eg, controller objects are pure fabrication So the Controller Principle is a special case of Pure Fabrication Principle Eg, PersistentStorage class is an example of Pure Fabrication

Principle: Pure Fabrication Design of objects can be divided into two groups: Representational decomposition Ie those related to representation of entities and their components, such as Sale, Vehicle, Document, … While these generally are in the problem domain, sometimes we have design representations that group them: eg DOM tree of a document is pure fabrication Behavioural decomposition Ie those related to representation of a process or algorithm. This includes controller classes for use cases, Command class, Strategy class, etc These are generally not in the problem domain model, and are mostly pure fabrication.

Principle: Indirection How to avoid direct coupling … How to de-couple objects … Assign the responsibility to an intermediate object to mediate between other components or services so that they are not directly coupled. Eg, Adaptor class to de-couple dependency on an explicit third-party interface. Eg, Façade classes to de-couple external objects from objects internal to the component. Eg, uses in CUWME?

Principle: Indirection “Most problems in computer science can be solved by adding another layer of indirection.” [David Wheeler] “Most problems in performance can be solved by removing another layer of indirection!”

Principle: Protected Variations How to design objects so that variations or instability in these elements does not have an undesirable impact on other elements? Identify points of predicted variation or instability; Assign responsibilities to create a stable interface around them. Eg, information hiding Eg, Polymorphism Principle: Allowing pluggable components using polymorphism of servers in a client- server relationship Cf, anticipated changes

Principle: Protected Variations Core mechanisms for Protected Variations Data encapsulation Interfaces Polymorphism Indirection Standards (eg APIs like JDBC) Note that these include virtual machines hiding OS, DB, network, etc

Principle: Protected Variations Other mechanisms for Protected Variations Data-driven designs Callback (eg Observer, Listener), service lookup Interpreter-driven designs Reflection or meta-level designs Structure hiding designs, such as composite pattern with iterator and visitor pattern for accessing and traversing the structure

Principle: Protected Variations Two kinds of change: Variation point Variations in the existing current system or requirements that must be supported in this system. Evolution point Speculative points of variation that may arise in the future, but which are not present in the existing requirements.

Principle: Protected Variations Examples in CUWME?

Principle: Low Coupling Assign responsibilities so that coupling remains low. Definition: Coupling is a measure of how strongly one element –is connected to, –has knowledge of, or –relies on other elements. An element with low coupling is not dependent on too many other elements. “too many” is context-dependent

Principle: Low Coupling Low coupling is an evaluative principle that can always be applied to evaluate alternative designs.

Principle: Low Coupling Forms of coupling: TypeX has an attribute that refers to a TypeY instance A TypeX object calls on services of a TypeY object TypeX has a method that references an instance of TypeY, or TypeY itself (ie as parameter, local variable, or return object) TypeX is a direct or indirect subclass of TypeY TypeY is an interface, and TypeX implements that interface.

Principle: High Cohesion Assign responsibilities so that cohesion remains high. Definition: (Functional) cohesion is a measure of how strongly related and focused the responsibilities of an element are. High cohesion is an evaluative principle that can always be applied to evaluate alternative designs.

Principle: Modularity = Low Coupling + High Cohesion “Modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules.” [Booch 1994]