Feb 200592.3913 Ron McFadyen1 Use Case Realizations with GRASP Patterns “The assignment of responsibilities and design of collaborations are very important.

Slides:



Advertisements
Similar presentations
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
Advertisements

Object Design Examples with GRASP
Jan 15, Ron McFadyen1 Ch 9. Use-case model: drawing System Sequence Diagrams Iteration: a simple cash-only success scenario of Process Sale.
Jan 23, Ron McFadyen1 SSD for a samplePOS Use Case Figure 13.1 Input Events invoke a system operation of the same name same idea as in object-oriented.
Oct Ron McFadyen Visibility Visibility: the ability of one object to see or have a reference to another object. e.g. When a register object.
Oct 22, Ron McFadyen1 Design Class Diagrams n Class diagram with – classes – associations – attributes – methods – navigability – interfaces,
Oct 2, Ron McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m Function:
March Ron McFadyen1 Ch 17: Use Case Realizations with GRASP Patterns Assigning responsibilities to objects to achieve user goals Section 17.4.
Feb R. McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m Function:
Jan Ron McFadyen1 Consider a simple cash-only Process Sale scenario 1. Customer arrives at a POS checkout with goods and/or services to purchase.
Fall 2009AXS-3913 Ron McFadyen Visibility Visibility: the ability of one object to see or have a reference to another object. e.g. When a register object.
Oct Ron McFadyen1 Ch 17: Use Case Realizations with GRASP Patterns P. 248: “The assignment of responsibilities and design of collaborations.
Jan 2005 Ron McFadyen1 Contracts Used to help understand requirements more completely (and so may not always be necessary) based on assertions;
January Ron McFadyen1 Ch 9. Use-case model: drawing System Sequence Diagrams Elaboration Iteration 1: a simple cash-only success scenario of.
NJIT Object Design Examples with GRASP Chapter 18 Applying UML and Patterns Craig Larman Presented By : Ajay Alegonda.
Fall 2009ACS Ron McFadyen1 The context maintains an instance of a concrete state subclass State Pattern Each subclass (concrete state) implements.
February Ron McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m.
ACS-3913Fall 2009 Ron McFadyen1 Contracts Used to help understand requirements more completely (and so may not always be necessary) based on assertions;
Oct Ron McFadyen Visibility Visibility: the ability of one object to see or have a reference to another object. e.g. When a register object.
Feb 4, Ron McFadyen1 Design Class Diagrams n Class diagram with – classes – associations – attributes – methods – navigability – (interfaces,
November Ron McFadyen1 Design Class Diagrams n Class diagram with – classes – associations – attributes – methods – navigability – interfaces,
Object-Oriented Analysis and Design
GRASP : Designing Objects with Responsibilities
November Ron McFadyen Visibility Visibility: the ability of one object to see or have a reference to another object. e.g. When a register object.
Sept Ron McFadyen1 Extend Relationship.
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.
9/18/011 Software Requirements Analysis and Design (Continued)
Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative Development Part III Elaboration Iteration I – Basic1.
CSSE 374: More GRASP’ing and Use Case Realization Steve Chenoweth Office: Moench Room F220 Phone: (812) These.
GRASP Pattern Zhen Jiang West Chester University
Chapter 18 Object Design Examples with GRASP. Objectives Design use case realizations –A use-case realization describes how a particular use case is realized.
1 Ch 18. Object Design Examples With Grasp Objectives Design use case realizations. Apply GRASP to assign responsibilities to classes. Apply UML to illustrate.
Chapter 7: Object Design Examples with GRASP. Objective Design use case realizations. Apply GRASP to assign responsibilities to classes. Apply UML to.
1 Unified Modelling Language OOA/OOD a summary of the book: Applying UML and Patterns, Craig Larman D. Dranidis October 2000 CITY College.
GRASP: Designing Objects With Responsibilities Chapter 17 Applying UML and Patterns -Craig Larman.
Chapter 18 Object Design Examples with GRASP 1CS6359 Fall 2011 John Cole.
Object Design Examples with GRASP (Ch. 18)
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.
Review ♦ System sequence diagram ♦ Domain model
Object-Oriented Analysis and Design 1 Mira Balaban & Arnon Sturm Object-Oriented Analysis and Design Session 4: Object-Oriented Software Construction.
1 Lecture 6: Operation Contracts. 2 Overview  What is contract ?  The guidelines for writing contracts for the system operations.  Use Case realizations.
Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11.
Operation Contracts. Primary way to describe system behavior is with use cases Operation contracts provide more details in terms of state changes to objects.
OO Methodology Elaboration Iteration 2 - Design Patterns -
Fall 2009ACS-3913 Ron McFadyen1 Use Case Realizations with GRASP Patterns “The assignment of responsibilities and design of collaborations are very important.
Copyright © Craig Larman All Rights Reserved COMP-350 Object-Oriented Analysis and Design GRASP: Designing Objects with Responsibilities Reference:
GRASP: Designing Objects With Responsibilities
OO Methodology Elaboration Phase Iteration 1- Part 3.
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.
1 Chapter 9: Operation Contracts Chapter 13 in Applying UML and Patterns Book.
Use-Case Model: Adding Detail with Operation Contracts.
1 Design Model Use-Case realizations with GRASP Larman chapter 17.
Oct 3, Ron McFadyen1 GRASP Patterns 1.Expert 2.Creator 3.Controller 4.Low Coupling 5.High Cohesion.
Design Model: Determining Visibility CH-18. Objectives Identify four kinds of visibility. Design to establish visibility. Illustrate kinds of visibility.
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
OO Methodology Elaboration Phase Iteration 1- Part 2.
Ch 17: Use Case Realizations with GRASP Patterns
Object Design Examples with GRASP
TK2023 Object-Oriented Software Engineering
Chapter 12: Collaboration Diagram - PART2
DESIGN MODEL: USE-CASE REALIZATIONS WITH GRASP PATTERNS
TK2023 Object-Oriented Software Engineering
Chapter 11: Class Diagram
CONTENTS Object-Oriented Modeling Using UML
Implementation Model: Mapping Designs to Code
Operation Contracts Ch. 11.
Chapter 11: Class Diagram
Design Model: Creating Design Class Diagrams
Presentation transcript:

Feb Ron McFadyen1 Use Case Realizations with GRASP Patterns “The assignment of responsibilities and design of collaborations are very important and creative steps during design” “there is no ‘magic’ or unjustifiable decisions in object design” “A use-case realization describes how a particular use case is realized within the design model, in terms of collaborating objects” makeNewSale enterItem endSale makePayment startUp You should review these sections

Feb Ron McFadyen2 Ch 17: Use Case Realizations with GRASP Patterns makeNewSale 1 st concern: who/what is going to be responsible for handling the system operation makeNewSale? Decision: Using the Controller Pattern … since there aren’t very many system operations and since Register (in our domain) represents the overall system, we choose Register as a “façade” controller.

Feb Ron McFadyen3 Use Case Realizations with GRASP Patterns By “Controller”, Register is our “façade” controller. makeNewSale() :Register

Feb Ron McFadyen4 Use Case Realizations with GRASP Patterns public class Register {… public makeNewSale() { … } We have just decided that Register must have a method makeNewSale Here, we are looking ahead to some code written to support the design Register makeNewSale …

Feb Ron McFadyen5 Use Case Realizations with GRASP Patterns 2 nd concern: who/what is going to be responsible for creating a Sale? Should Register delegate the responsibility or …? Since Register (in the domain) actually records a Sale then, by “Creator”, we decide that Register will do this. Register has the data and it needs to keep track of a Sale, so …

Feb Ron McFadyen6 Use Case Realizations with GRASP Patterns By “Creator”, Register creates a Sale. makeNewSale() :Register create() :Sale

Feb Ron McFadyen7 Use Case Realizations with GRASP Patterns public class Register {… Private Sale sale; … public makeNewSale() { sale = new Sale(); } The method makeNewSale creates the sale object Here, we are looking ahead to some code written to support the design

Feb Ron McFadyen8 Use Case Realizations with GRASP Patterns 3 rd concern: Sale needs to know of its SalesLineItems. A container for these is required. Who/What should create this? Since Sale will contain the lines, by “Creator”, we decide that Sale will do this…

Feb Ron McFadyen9 Use Case Realizations with GRASP Patterns By “Creator”, Register creates a Sale. makeNewSale() :Register create() :Sale create() : :SalesLineItem

Feb Ron McFadyen10 Use Case Realizations with GRASP Patterns By “Creator”, Register creates a Sale. makeNewSale() :Register create() :Sale create() lineItems: List 3 rd edition

Feb Ron McFadyen11 Use Case Realizations with GRASP Patterns public class Sale {private List lineItems = new ArrayList(); private Date date = new Date(); private boolean isComplete = false; private Payment payment; … The constructor for Sale creates the container for the line items. Sale contains a list of line items

Feb Ron McFadyen12 Use Case Realizations with GRASP Patterns enterItem 1 st concern: who/what is going to be responsible for handling the system operation enterItem? We continue using the Controller Pattern … Register is responsible for handling enterItem.

Feb Ron McFadyen13 Use Case Realizations with GRASP Patterns Contract for enteritem specifies Preconditions: A Sale is underway Postconditions: salesLineItem is created It is associated with the current Sale Its quantity is set It is associated with a ProductSpecification By Creator, Sale can do this Sale stores the new sales line item in its collection The product specification will need to be found

Feb Ron McFadyen14 Use Case Realizations with GRASP Patterns enterItem() :Register:Sale : :SalesLineItem 2:makeLineItem() 2.1:create() 2.2:add() Message 2 … see later slide

Feb Ron McFadyen15 Use Case Realizations with GRASP Patterns enterItem() :Register:Sale : SalesLineItem 2:makeLineItem() 2.1:create() 2.2:add() Message 2 … see later slide lineItems: List 3 rd edition

Feb Ron McFadyen16 Use Case Realizations with GRASP Patterns public class Sale {… public void makeLineItem (…, …) { lineItems.add ( new SalesLineItem (…, …) ) ; } The “add” message sent to the multiobject is handled within Sale. Sale has a list of line items The “create” message for a new sales line item

Feb Ron McFadyen17 Use Case Realizations with GRASP Patterns public class SalesLineItem {private int quantity; private ProductSpecification productSpec; public void SalesLineItem (…spec, …quantity) { this.productSpec = spec ; this.quantity = quantity } The constructor for a sales line item arranges that the sales line item knows its product specification and its quantity

Feb Ron McFadyen18 Use Case Realizations with GRASP Patterns enterItem 2 nd concern: who/what is going to be responsible for finding a match for a product specification? For doing a lookup? Who has knowledge of product specifications? Who is capable of doing a lookup? Expert suggests the product catalogue is the best candidate. The product catalogue contains the product specifications … the product catalogue has the information, it is the expert.

Feb Ron McFadyen19 Use Case Realizations with GRASP Patterns enterItem() :Register : :ProductSpecification :ProductCatalog 1:getSpecification() 1.1:find()

Feb Ron McFadyen20 Use Case Realizations with GRASP Patterns enterItem() :Register :ProductCatalog 1:getSpecification() 1.1:get() : Map 3 rd edition

Feb Ron McFadyen21 Use Case Realizations with GRASP Patterns public class ProductCatalog { private Map productSpecifications = new HashMap(); … public ProductSpecification getSpecification (ItemID id) { Return( …. productSpecifications.get ( id ); } Collection of product specifications Method to find a specific item Handles the “find” message

Feb Ron McFadyen22 Use Case Realizations with GRASP Patterns enterItem() :Register:Sale : :ProductSpecification :ProductCatalog : :SalesLineItem 1:getSpecification() 1.1:find() 2:makeLineItem() 2.1:create() 2.2:add()

Feb Ron McFadyen23 Use Case Realizations with GRASP Patterns enterItem() :Register:Sale :ProductCatalog :SalesLineItem 1:getSpecification() 1.1get() 2:makeLineItem() 2.1:create() 2.2:add() : Map 3 rd edition lineItems: List

Feb Ron McFadyen24 Use Case Realizations with GRASP Patterns Given the previous collaboration, what methods/responsibilities have been assigned to the various classes? RegisterSale ProductCatalog SalesLineItem