GRASP Patterns M Taimoor Khan

Slides:



Advertisements
Similar presentations
GRASP: Designing Objects with Responsibilities
Advertisements

Object-Oriented Analysis and Design CHAPTER 17, 25: GRASP PATTERNS 1.
Chapter 1 Object Oriented Analysis and Design. UML, Patterns, and Object-Oriented Analysis and Design  The essential skills for the creation of well-designed,
Oct 2, Ron McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m Function:
March R McFadyen1 Architecture Architecture involves the set of significant decisions about the organization of a software system, decisions.
Feb R. 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.
NJIT More GRASP Patterns Chapter 22 Applying UML and Patterns Craig Larman Prepared By: Krishnendu Banerjee.
February Ron McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m.
Low Coupling High Cohesion
NJIT 1 GRASP: Designing Objects with Responsibilities Chapter 17 Applying UML and Patterns Craig Larman.
GRASP : Designing Objects with Responsibilities
Fall 2009ACS-3913 Ron McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Date: 1753 an interpretation.
Feb 4, Ron McFadyen1 founded on principles of good OO design idea was first put forth by Christopher Alexander (1977) in their work concerning.
CSSE 374: More GRASP’ing and Use Case Realization Steve Chenoweth Office: Moench Room F220 Phone: (812) These.
Objectives Design Class Diagrams Issues in system design Generalization Review UML papers.
Chapter 13 Starting Design: Logical Architecture and UML Package Diagrams.
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.
GRASP Patterns Presented By Dr. Shazzad Hosain. Patterns A pattern describes a problem and solution, and given a name. Examples are Singleton, Adapter,
An Introduction to Software Architecture
Chapter 17. GRASP General Responsibility Assignment Software Patterns (Principles) OOD: after identifying requirements, create domain model, define responsiblities.
BTS430 Systems Analysis and Design using UML Domain Model Part 1—Finding Conceptual Classes.
Systems Analysis and Design in a Changing World, 6th Edition
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
Architecture GRASP Realization of use cases in interaction diagrams Design class diagram Design ( how )
Requirements To Design--Iteratively Chapter 12 Applying UML and Patterns Craig Larman.
1 On to Object Design Chapter 14 Applying UML and Patterns.
BTS430 Systems Analysis and Design using UML Design Patterns.
CS 325: Software Engineering February 12, 2015 Applying Responsibility-Assignment Patterns Design Patterns Situation-Specific Patterns Responsibility-Assignment.
GRASP: Designing Objects With Responsibilities
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
11 Partnership for Performance How to hear this lecture Click on the icon: to hear the narration for each slide.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
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.
Chapter 13 Logical Architecture and UML Package Diagrams 1CS6359 Fall 2012 John Cole.
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)
Introduction to Design Patterns Part 1. © Lethbridge/Laganière 2001 Chapter 6: Using design patterns2 Patterns - Architectural Architectural Patterns:
Object-Oriented Analysis and Design Mar 9, 2008.
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.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
TK2023 Object-Oriented Software Engineering CHAPTER 8 LOGICAL ARCHITECTURE.
Copyright © Craig Larman All Rights Reserved COMP-350 Object-Oriented Analysis and Design GRASP: Designing Objects with Responsibilities Reference:
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.
OOD OO Design. OOD-2 OO Development Requirements Use case analysis OO Analysis –Models from the domain and application OO Design –Mapping of model.
General Principles in Assigning Responsibilities Responsibilities Responsibility-Driven Design CRC Cards GRASP.
OO Methodology Elaboration Phase Iteration 1- Part 2.
TK2023 Object-Oriented Software Engineering
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,
Logical Architecture and UML Package Diagrams. The logical architecture is the large-scale organization of the software classes into packages, subsystems,
GRASP – Designing Objects with Responsibilities
Chapter 12: Collaboration Diagram - PART2
Conception OBJET GRASP Patterns
DESIGN MODEL: USE-CASE REALIZATIONS WITH GRASP PATTERNS
TK2023 Object-Oriented Software Engineering
Presentation on GRASP Patterns Submitted by
Software Quality Engineering
Apply Expert, Creator, Controller, Low Coupling, High Cohesion
GRASP : Designing Objects with Responsibilities
Chapter 13 Logical Architecture.
Starting Design: Logical Architecture and UML Package Diagrams
Chapter 13 Logical Architecture.
An Introduction to Software Architecture
Presentation transcript:

GRASP Patterns M Taimoor Khan

Patterns Are not invented. They are harvested from existing solutions. Are given a name to aid in communications. Are documented in a rigorous fashion Sometimes conflict with each other. For example: you apply a patterns to solve one problem, but by doing so, you may introduce others. – This is called a contradiction, or side-effect. – These are the tradeoffs designers have to deal with!

GRASP Patterns Larman introduces a set of basic patterns that he calls GRASP: General Responsibility Assignment Software Pattern Five GRASP Patterns: – Information Expert – Creator – High Cohesion – Low Coupling – Controller

GRASP -Information Expert Problem : A system will have hundreds of classes. How do I begin to assign responsibilities to them? Solution : Assign responsibility to the Information Expert–the class that has the information necessary to fulfil the responsibility. Mechanics : – Step 1: Clearly state the responsibility – Step 2: Look for classes that have the information we need to fulfil the responsibility. – Step 3: Domain Model – Step 4: Sketch out some interaction diagrams. – Step 5: Update the class diagram.

GRASP -Information Expert Discussion Points: – Throughout the process of assigning a responsibility, you may discover many lower- level responsibilities Contradictions: – Sometimes application of the Expert Pattern is undesirable or may have conflict with other responsibilities

GRASP -Information Expert

GRASP –Creator Pattern Problem : Who creates new instances of some class? Solution : – Let class A create an instance of class B if…. – A aggregates(whole-part relationship) B objects – A contains B objects – A records instances of B objects – A closely uses B objects – A has initialization data that is needed when creating B objects. Mechanics: Step 1: Look at Domain / Design model and ask: “Who should be creating these classes”? Step 2:Look for classes that create, aggregate, etc. Step 3:Sketch or update interaction / class diagrams. Contradictions: Sometimes it’s time consuming

GRASP –Creator Pattern

GRASP –Low Coupling Concept –Coupling: Coupling refers to dementedness, or connectedness. Our goal is to design for low coupling, so that changes in one element (sub-system, system, class, etc.) will limit changes to other elements. Low coupling supports increased reuse. Taken to the extreme, what if we were to design a set of classes with no coupling. We can’t avoid coupling, but we want to make sure we understand the implications of introducing it and/or the tradeoffs of reducing it.

GRASP –Low Coupling Problem: How do you support low dependency, low change impact, and increased reuse. Solution: Assign responsibility so responsibility remains low. Mechanics: – Look for classes with many associations to other classes. – Look for methods that rely on a lot of other methods (or methods in other classes, i.e. dependencies. – Rework your design as needed.

GRASP –Low Coupling

GRASP –High Cohesion Concept –Cohesion: – Cohesion is a measure of “relatedness” – High Cohesion says elements are strongly related to one another – Low Cohesion says elements are not strongly related to one another Low Cohesion examples: System level : ATM with a use case (function) called “Teller Reports” Class level: A Student class with a method called “getDrivingRecord(). Method level: Methods with the word “And” or “Or” in them. Also applies to subsystem (package) level, component level, etc. –Designs with low cohesion are difficult to maintain and reuse. –One of the fundamental goals of an effective design is to achieve high cohesion with low coupling

GRASP –High Cohesion Problem: How do you keep complexity manageable? Solution : Assign responsibility so that cohesion remains high. Mechanics : Look for classes with too-few or disconnected methods. Look for methods that do too much (hint: method name) Rework your design as needed. Contradictions: High Cohesion and low coupling are competing forces.

GRASP –High Cohesion Additional: Larman describes degrees of cohesion, from very low to high. For now, just consider that in general, classes with a small number of functionally related methods is more desirables than bloated classes with disconnected methods. Look at the sequence diagrams for adding a payment to a sale, but this time from the perspective of cohesion. Which version supports high cohesion, and why? This example illustrates that: High cohesion and low coupling can be competing forces. Design is not so clear cut, e.g. it is not always an exact science

GRASP -Controller Problem: Who handles events from external actors, e.g. startup(), playSongs(), etc? Solution: Assign the responsibility to a controller class, such as: – A class that represents the overall system, device, or subsystem. Example: Jukebox. – A class that represents a use case. Example: makeSaleHandler. makeSaleCoordinator, etc. – These classes often don’t do the work, but delegate it to others. Additional: – The decision to create system controllers vs. use case controllers are often driven by the dynamics of high cohesion vs. low coupling.

GRASP –Controller Additional : Watch for bloated controllers. From an architectural perspective, systems are usually broken upon to layers, or tiers. Example 2 tier client-server, 3 tier, n tier, etc. The UI objects are in the presentation layer. The business objects representing the problem domain are in the application or domain layer. The objects representing databases, network connections, etc. are in the Technical or infrastructure layer(s) Layering and related decisions are frequently made by an Architect. Controllers typically receive requests from UI (interface objects). It is not a good idea to put business logic in UI objects

Assigning Responsibilities –Other Sources CRC Cards: –Another popular technique to assigning responsibilities to classes is to use CRC cards CRC = Class: Responsibility: Collaboration –Introduced by Kent Beck and Ward Cunnigham