Chapter 7: Object Design Examples with GRASP. Objective Design use case realizations. Apply GRASP to assign responsibilities to classes. Apply UML to.

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-Oriented Analysis and Design
Object Design Examples with GRASP
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:
Feb R. McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m Function:
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.
Object-Oriented Software Engineering Practical Software Development using UML and Java Design Patterns Sources: Chapter 6: Using Design Patterns, and Chapter.
Object-Oriented Analysis and Design
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.
GRASP Design Patterns: Designing Objects with Responsibilities
Chapter 9 Domain Models. Domain Model in UML Class Diagram Notation A “visual dictionary”
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,
Chapter 18 Object Design Examples with GRASP. Objectives Design use case realizations –A use-case realization describes how a particular use case is realized.
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
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 26 GoF Design Patterns. The Adapter Design Pattern.
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.
GRASP: Designing Objects With Responsibilities
Object Design Examples with GRASP (Ch. 18)
Object-Oriented Analysis and Design Mar 11, 2008.
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.
Object-Oriented Design Part 2
Next Gen POS Example GRASP again. Same Patterns Different Example!
What to remember from Chap 13 (Logical architecture)
Object-Oriented Analysis and Design Mar 9, 2008.
OO Methodology Elaboration Iteration 2 - Design Patterns -
TK2023 Object-Oriented Software Engineering CHAPTER 12 Introduction to Responsibility-Driven Design.
OO Design Roshan Chitrakar. Analysis to Design Do the RIGHT thing Do the RIGHT thing Requirement Analysis Requirement Analysis Domain Modeling with addition.
Object-Oriented Analysis and Design Week 11, 2009.
Copyright © Craig Larman All Rights Reserved COMP-350 Object-Oriented Analysis and Design GRASP: Designing Objects with Responsibilities Reference:
GRASP: Designing Objects With Responsibilities
Chapter 17 Designing with Responsibilities. Fig
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 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.
OO Methodology Elaboration Iteration 3 – Part 3 - More Design Patterns -
General Principles in Assigning Responsibilities Responsibilities Responsibility-Driven Design CRC Cards GRASP.
OO Methodology Elaboration Phase Iteration 1- Part 2.
Object Design Examples with GRASP
Elaboration popo.
TK2023 Object-Oriented Software Engineering
Chapter 9 Domain Models.
Chapter 12: Collaboration Diagram - PART2
Conception OBJET GRASP Patterns
Chapter 11: Collaboration Diagram - PART1
DESIGN MODEL: USE-CASE REALIZATIONS WITH GRASP PATTERNS
TK2023 Object-Oriented Software Engineering
Presentation on GRASP Patterns Submitted by
Apply Expert, Creator, Controller, Low Coupling, High Cohesion
GRASP : Designing Objects with Responsibilities
GRASP Design Patterns: Designing Objects with Responsibilities
GRASP (General Responsibility Assignment Software Patterns)
Chapter 11: Class Diagram
Next Gen POS Example GRASP again.
Chapter 11: Class Diagram
Design Model: Creating Design Class Diagrams
Presentation transcript:

Chapter 7: Object Design Examples with GRASP

Objective Design use case realizations. Apply GRASP to assign responsibilities to classes. Apply UML to illustrate and think through the design of objects.

7.1. What is a Use Case Realization? A use-case realization –Describes how a particular use case is realized within the Design Model, in terms of collaborating objects. the connection between the requirements expressed as use cases and the object design that satisfies the requirements.

7.1. What is a Use Case Realization?

7.2. Artifact Comments SSDs, System Operations, Interaction Diagrams, and Use Case Realizations

7.2. Artifact Comments The Domain Model and Use Case Realizations – The Domain Model inspires some of the software objects, such as a Sale conceptual class and Sale software class

7.3. What's Next? The remainder of this chapter is organized as follows: –A relatively detailed discussion of the design of the NextGen POS. –Likewise, for the Monopoly case study, Applying UML and patterns to these case studies. let's get into the details…

7.4. Use Case Realizations for the NextGen Iteration –Who should be responsible for calculating the Sale total? By Expert, it should be the Sale itself, implemented as a getTotal method. –Who should be responsible for calculating the SalesLineItem subtotal? By Expert, it should be the SalesLineItem itself, implemented as a getSubtotal method. –Who should be responsible for providing the ProductDescription price? By Expert, it should be the ProductDescription itself, implemented as a getPrice operation. My goodness, that was detailed!

7.4. Use Case Realizations for the NextGen Iteration The Sale.getTotal Design

7.4. Use Case Realizations for the NextGen Iteration

How to Design makePayment? –Two Candidates for Creating the Payment Register –By Creator “register" records account information in real domain “register" records account information in real domain –By Expert Register is the controller that receives the system operation makePayment message. Sale –It will closely use a Payment

7.4. Use Case Realizations for the NextGen Iteration When there are alternative design choices –take a closer look at the cohesion and coupling implications of the alternatives –and possibly at the future evolution pressures on the alternatives

7.4. Use Case Realizations for the NextGen Iteration Logging a Sale –Who is responsible for knowing all the logged sales and doing the logging? Store –the logged sales are strongly related to its finance SalesLedger –makes sense as the design grows and the Store becomes incohesive –SalesLedger is not in domain model

7.4. Use Case Realizations for the NextGen Iteration

Calculating the Balance –Who is responsible for knowing the balance? need the sale total and payment cash tendered

7.4. Use Case Realizations for the NextGen Iteration The Final NextGen DCD for Iteration-1

7.4. Use Case Realizations for the NextGen Iteration How to Connect the UI Layer to the Domain Layer? –An initializer object called from the application starting method (e.g., the Java main method) creates both a UI and a domain object and passes the domain object to the UI. –A UI object retrieves the domain object from a well-known source, such as a factory object that is responsible for creating domain objects.

7.4. Use Case Realizations for the NextGen Iteration

How to show the running total in UI –Add a getTotal method to the Register. Lower coupling from the UI to the domain layer make Register less cohesive. –A UI directly sends messages to the Sale. increases the coupling from the UI to the domain layer.

7.4. Use Case Realizations for the NextGen Iteration

Initialization and the 'Start Up' Use Case –When to Create the Initialization Design? Do the initialization design last. –How do Applications Start Up? create an initial domain object or a set of peer initial domain objects –in the starting main method or in a Factory object called from the main method the initial domain object is responsible for the creation of its direct child domain objects.

7.4. Use Case Realizations for the NextGen Iteration public class Main { public static void main( String[] args ) { // Store is the initial domain object. // The Store creates some other domain objects. Store store = new Store(); Register register = store.getRegister(); ProcessSaleJFrame frame = new ProcessSaleJFrame( register );......}}

7.4. Use Case Realizations for the NextGen Iteration Choosing the Initial Domain Object –a class at or near the root of the containment or aggregation hierarchy of domain objects. Store.create Design –Create a Store, Register, ProductCatalog, and ProductDescriptions. –Associate the ProductCatalog with ProductDescriptions. –Associate Store with ProductCatalog. –Associate Store with Register. –Associate Register with ProductCatalog

7.4. Use Case Realizations for the NextGen Iteration Multiplicity between classes of objects in the Domain Model and Design Model may not be the same.

7.5. Use Case Realizations for the Monopoly Iteration

How to Design playGame? –Choosing the Controller Class MonopolyGame / MGame PlayMonopolyGameHandlerPlayMonopolyGameSession

7.5. Use Case Realizations for the Monopoly Iteration The Game-Loop Algorithm –turn a player rolling the dice and moving the piece –round all the players taking one turn Now the game loop: for N rounds for each Player p p takes a turn Who is Responsible for Controlling the Game Loop?

7.5. Use Case Realizations for the Monopoly Iteration Information Needed Who Has the Information the current round count No object has it yet, but assigning this to the MonopolyGame object is justifiable. all the players MonopolyGame is a good candidate.

7.5. Use Case Realizations for the Monopoly Iteration playRound helper method –Factors the play-single-round logic into a helper method; it is good to organize cohesive chunks of behavior into small separate methods. –Good OO method design encourages small methods with a single purpose. This supports High Cohesion at the method level.

7.5. Use Case Realizations for the Monopoly Iteration Who Takes a Turn? –Rolling the dice –Moving a piece to the square indicated by the total of the dice face values. a naive reaction might be to say "a Player object should take the turn"

7.5. Use Case Realizations for the Monopoly Iteration Information Needed Who Has the Information current location of the player a Piece knows its Square and a Player knows its Piece. the two Die objects MonopolyGame is a candidate since we think of the dice as being part of the game. all the squares Board is a good candidate. Interesting Problem! –There are three partial information experts for the "take a turn" responsibility

7.5. Use Case Realizations for the Monopoly Iteration When there are multiple partial information experts –place the responsibility in the dominant one the object with the majority of the information When there are alternative design choices, – consider the coupling and cohesion impact of each, and choose the best. When there is no clear winner –consider probable future evolution of the software objects and the impact in terms of Information Expert, cohesion, and coupling.

7.5. Use Case Realizations for the Monopoly Iteration

Taking a Turn –calculating a random number total between 2 and 12 (the range of two dice) Die –calculating the new square location Board –moving the player's piece from an old location to a new square location Piece Who Coordinates All This? –Player The Problem of Visibility –Player need visibility to the Die, Board, and Piece objects

7.5. Use Case Realizations for the Monopoly Iteration

// style #1; used in the official solution public void roll() { faceValue = // random num generation } public int getFaceValue() { return faceValue; } // style #2; why is this poor? public int roll() { faceValue = // random num generation return faceValue; }

7.5. Use Case Realizations for the Monopoly Iteration Command-Query Separation Principle –a command method that performs an action often has side effects such as changing the state of objects, and is void –a query that returns data to the caller and has no side effects

7.5. Use Case Realizations for the Monopoly Iteration Initialization and the 'Start Up' Use Case

Questions & Answers