Oct 3, 200291.3913 Ron McFadyen1 GRASP Patterns 1.Expert 2.Creator 3.Controller 4.Low Coupling 5.High Cohesion.

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
Object-Oriented Analysis and Design CHAPTER 17, 25: GRASP PATTERNS 1.
Jan 15, Ron McFadyen1 Ch 9. Use-case model: drawing System Sequence Diagrams Iteration: a simple cash-only success scenario of Process Sale.
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 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.
Oct Ron McFadyen1 Ch 17: Use Case Realizations with GRASP Patterns P. 248: “The assignment of responsibilities and design of collaborations.
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.
February Ron McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m.
Feb Ron McFadyen1 Use Case Realizations with GRASP Patterns “The assignment of responsibilities and design of collaborations are very important.
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.
GRASP Design Patterns: Designing Objects with Responsibilities
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.
GRASP PATTERNS Information Expert (Expert) Creator Controller © Lethbridge/Laganière 2001 Chapter 6: Using design patterns1.
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.
Architecture GRASP Realization of use cases in interaction diagrams Design class diagram Design ( how )
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.
INFO 620Lecture #61 Information Systems Analysis and Design More Class Modeling; Patterns INFO 620 Glenn Booker.
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.
Copyright © Craig Larman All Rights Reserved Responsibility-Driven Design with the GRASP Patterns.
Next Gen POS Example GRASP again. Same Patterns Different Example!
Object-Oriented Analysis and Design 1 Mira Balaban & Arnon Sturm Object-Oriented Analysis and Design Session 4: Object-Oriented Software Construction.
GRASP: Designing Objects with Responsibilities
IntellAgile Copyright © 2002 Craig Larman. All rights reserved. Object Design and Use- Case Realizations with GRASP Patterns.
Object-Oriented Analysis and Design Mar 9, 2008.
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.
OO Design Roshan Chitrakar. Analysis to Design Do the RIGHT thing Do the RIGHT thing Requirement Analysis Requirement Analysis Domain Modeling with addition.
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:
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 Object Oriented Analysis and Design System Events & Contracts.
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
TK2023 Object-Oriented Software Engineering
Chapter 12: Collaboration Diagram - PART2
Conception OBJET GRASP Patterns
DESIGN MODEL: USE-CASE REALIZATIONS WITH GRASP PATTERNS
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
Chapter 11: Class Diagram
Implementation Model: Mapping Designs to Code
Next Gen POS Example GRASP again.
Chapter 11: Class Diagram
Design Model: Creating Design Class Diagrams
Presentation transcript:

Oct 3, Ron McFadyen1 GRASP Patterns 1.Expert 2.Creator 3.Controller 4.Low Coupling 5.High Cohesion

Oct 3, Ron McFadyen2 Expert n Assign a responsibility to the object that has the information necessary to fulfill it. – “That which has the information, does the work.” – Not a sophisticated idea - rather, it is common sense – E.g., What software object calculates grand total? What information is needed to do this? What object or objects has the majority of this information.

Oct 3, Ron McFadyen3 Expert Example. In the NextGEN POS application, it is necessary to know the grand total of a sale. Where should that responsibility be placed? {We will be assigning a few responsibilities in this example} Expert suggests that we should look for a class that has the information needed to determine the grand total. If our design is just beginning, we look at the Domain Model and bring the pertinent conceptual classes into the class model Pages

Oct 3, Ron McFadyen4 What information is needed to determine the grand total? It is necessary to know all the SalesLineItem instances of a sale and to sum of their subtotals. A Sale instance is aware of these … Sale is the Expert choice for having the responsibility of knowing the grand total.

Oct 3, Ron McFadyen5 Expert leads us to place the method getTotal() in Sale

Oct 3, Ron McFadyen6 A line item knows its quantity and the associated Product, so it is the expert … SalesLineItem should determine the line item subtotal

Oct 3, Ron McFadyen7 Only the Product Specification knows the price; so Product Specification needs a method...

Oct 3, Ron McFadyen8 Creator n What object should have the responsibility to create an X? – Ignores special-case patterns such as Factory. n Choose an object C, such that: – C contains or aggregates X – C closely uses X – C records instances of X objects – C closely uses X objects – C has the initializing data for X

Oct 3, Ron McFadyen9 Example: Who should be responsible for creating a SalesLineItem? Since Sale “contains” SalesLineItems, Creator suggests Sale as the candidate for this responsiblity

Oct 3, Ron McFadyen10 :Register :SalesLineItem makeLineItem(qty) create(qty) :Sale We assign the responsibility of creating a SalesLineItem to Sale – Sale will have a method makeLineItem

Oct 3, Ron McFadyen11 What object in the domain (or application layer) receives requests for work from the UI layer? Controller

Oct 3, Ron McFadyen12 Basic Principle: Interface objects should not have responsibility for handling system events Assign responsibility to a Controller, an object in the application/domain layer. Choose, or invent, an object in the application layer for this. Controller: a non-user interface object responsible for receiving or handling a system event. In the Process Sale Use Case, there are several system events: makeNewSale, enterItem, endSale, makePayment

Oct 3, Ron McFadyen13 makeNewSale enterItem endSale makePayment Part of Figure 9.1 System Operations

Oct 3, Ron McFadyen14 Candidates: – An object whose name reflects the use case. e.g. ProcessSaleHandler – An object whose name reflects the overall server, business, or large-scale entity. A kind of “façade” object e.g. Register, Store, Cashier Choose, or invent, an object in the application layer for this.

Oct 3, Ron McFadyen15 F Other choices are Store and Cashier F Register was chosen over store as it is conceptually closer to the system event F Register was chosen over Cashier as it is really an actor the runs the Register F Thus Register is the logical choice

Oct 3, Ron McFadyen16 Figure Allocating System Operations Register has been chosen to handle all system operations Ch 20 shows the code for this Use Case handlers are chosen

Oct 3, Ron McFadyen17 public void endSale ( ) { sale.becomeComplete(); } public void enterItem ( String id, int quantity ) { ProductSpecification spec = catalog.getSpecification( id ); sale.makeLineItem( spec, quantity ); } public void makeNewSale ( ) { sale = new Sale(); } public void makePayment (Money cashTendered ) { sale.makePayment( cashTendered ); } System event handling in Register The Controller doesn’t do much … delegates work to other objects … it receives the request and coordinates fulfillment

Oct 3, Ron McFadyen18 The Controller pattern promotes reuse UI code is not intertwined with system event code UI can be replaced Multiple UIs could be utilized When a legal sequence of operations must occur, state information must be kept … the Controller object is an excellent choice for this information

Oct 3, Ron McFadyen19 F Every business system should have a controller F A controller is class whose job it is to coordinate the system events F The controller sees to it the messages are sent to the correct objects in the model – it delegates F The reason to have a controller is to separate the business model from the visual logic called a view F This is often called a MVC (Model View Controller) separation

Oct 3, Ron McFadyen20 F Advantage - is that the changes to the model do not affect the GUI (view) logic F Advantage - is that the changes to the GUI (view) do not affect the model logic – could have multiple GUIs – GUI is replaceable F It provides a buffer between the visual (view) and the business logic (model)

Oct 3, Ron McFadyen21 Figure desirable coupling of interface layer to domain layer