March 200391.3913 Ron McFadyen1 Ch 17: Use Case Realizations with GRASP Patterns Assigning responsibilities to objects to achieve user goals Section 17.4.

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 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:
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.
Object-Oriented Analysis and Design
Jan 2005 Ron McFadyen1 Contracts Used to help understand requirements more completely (and so may not always be necessary) based on assertions;
NJIT Object Design Examples with GRASP Chapter 18 Applying UML and Patterns Craig Larman Presented By : Ajay Alegonda.
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,
Feb Ron McFadyen1 Use Case Realizations with GRASP Patterns “The assignment of responsibilities and design of collaborations are very important.
November Ron McFadyen1 Design Class Diagrams n Class diagram with – classes – associations – attributes – methods – navigability – interfaces,
Object-Oriented Analysis and Design
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.
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.
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.
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.
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
GRASP Principles. How to Design Objects The hard step: moving from analysis to design How to do it? –Design principles (Larman: “patterns”) – an attempt.
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.
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)
17. GRASP—Designing Objects with Responsibilities III CSE5324 Lecture Quiz 17 due at 5 PM Thursday, 8 October 2015.
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.
Fall 2009ACS-3913 Ron McFadyen1 Use Case Realizations with GRASP Patterns “The assignment of responsibilities and design of collaborations are very important.
OO Design Roshan Chitrakar. Analysis to Design Do the RIGHT thing Do the RIGHT thing Requirement Analysis Requirement Analysis Domain Modeling with addition.
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.
1 Object Oriented Analysis and Design System Events & Contracts.
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
Conception OBJET GRASP Patterns
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:

March Ron McFadyen1 Ch 17: Use Case Realizations with GRASP Patterns Assigning responsibilities to objects to achieve user goals Section 17.4 makeNewSale Section 17.5 enterItem Section 17.6 endSale Section 17.7 makePayment Section 17.8 Start Up You should review these sections

March Ron McFadyen2 Ch 17: Use Case Realizations with GRASP Patterns Who/What is going to be responsible for : Handling the system operation makeNewSale? Creating a Sale? Who/What should create the container of SalesLineItems? Handling the System operation enterItem? Creating a Saleslineitem? Finding a match for a product specification? For doing a lookup? Handling the system operation endSale? Setting the isComplete attribute of Sale to true? Calculating the sale total? Calculating the SalesLineItem subtotal? Providing the ProductSpecification price? Handling the system operation makePayment? Creating a Payment instance? ………. Which GRASP pattern justified the decision?

March Ron McFadyen3 Ch 17: Use Case Realizations with GRASP Patterns Section 17.4 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.

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

March Ron McFadyen5 Ch 17: Use Case Realizations with GRASP Patterns Page 314 public class Register {… public makeNewSale() { … } We have just decided that Register must have a method makeNewSale

March Ron McFadyen6 Ch 17: 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 …

March Ron McFadyen7 Ch 17: Use Case Realizations with GRASP Patterns By “Creator”, Register creates a Sale. makeNewSale() :Register create() :Sale

March Ron McFadyen8 Ch 17: Use Case Realizations with GRASP Patterns Page 314 public class Register {… Private Sale sale; … public makeNewSale() { sale = new Sale(); } The method makeNewSale creates the sale object

March Ron McFadyen9 Ch 17: 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…

March Ron McFadyen10 Ch 17: Use Case Realizations with GRASP Patterns By “Creator”, Register creates a Sale. makeNewSale() :Register create() :Sale create() : :SalesLineItem

March Ron McFadyen11 Ch 17: Use Case Realizations with GRASP Patterns Page 315 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

March Ron McFadyen12 Ch 17: Use Case Realizations with GRASP Patterns Section 17.5 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.

March Ron McFadyen13 Ch 17: 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

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

March Ron McFadyen15 Ch 17: Use Case Realizations with GRASP Patterns Page 315 public class Sale {… public void makeLineItem (…, …) { lineItems.add ( new SalesLineItem (…, …) ) ; } The “add” message sent to the multiobject The “create” message for a new sales line item

March Ron McFadyen16 Ch 17: Use Case Realizations with GRASP Patterns Page 316 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

March Ron McFadyen17 Ch 17: Use Case Realizations with GRASP Patterns Section 17.5 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.

March Ron McFadyen18 Ch 17: Use Case Realizations with GRASP Patterns enterItem() :Register : :ProductSpecification :ProductCatalog 1:getSpecification() 1.1:find()

March Ron McFadyen19 Ch 17: Use Case Realizations with GRASP Patterns Page 316 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

March Ron McFadyen20 Ch 17: 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()

March Ron McFadyen21 Ch 17: Use Case Realizations with GRASP Patterns Given the previous collaboration, what methods/responsibilities have been assigned to the various classes? RegisterSale ProductCatalog SalesLineItem