TK2023 Object-Oriented Software Engineering

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.
Feb R. McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m Function:
Drawing System Sequence Diagrams
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 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.
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 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.
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.
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
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 )
1 Ch 18. Object Design Examples With Grasp Objectives Design use case realizations. Apply GRASP to assign responsibilities to classes. Apply UML to illustrate.
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.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
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)
Chapter 1 Applying UML and Patterns. The Need for Software Blueprints Knowing an object-oriented language and having access to a library is necessary.
Drawing System Sequence Diagrams
COMP-350 Object-Oriented Analysis and Design Drawing System Sequence Diagrams Reference: Larman, Chapter 9.
Object-Oriented Analysis and Design Mar 9, 2008.
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.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
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:
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.
Oct 3, Ron McFadyen1 GRASP Patterns 1.Expert 2.Creator 3.Controller 4.Low Coupling 5.High Cohesion.
General Principles in Assigning Responsibilities Responsibilities Responsibility-Driven Design CRC Cards GRASP.
1 Object Oriented Analysis and Design System Events & Contracts.
OO Methodology Elaboration Phase Iteration 1- Part 2.
TK2023 Object-Oriented Software Engineering CHAPTER 13d GRASP Patterns: High Cohesion.
TK2023 Object-Oriented Software Engineering
Logical Architecture and UML Package Diagrams. The logical architecture is the large-scale organization of the software classes into packages, subsystems,
Object Design Examples with GRASP
GRASP – Designing Objects with Responsibilities
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
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
System Sequence Diagrams(SSD)
Operation Contracts Ch. 11.
Presentation transcript:

TK2023 Object-Oriented Software Engineering CHAPTER 13e GRASP Patterns: Controller

GRASP PATTERNS: CONTROLLER Problem What first object beyond the UI layer receives and coordinates (“controls”) a system operation?

Treat system as a black box : System : Cashier makeNewSale( ) enterItem(itemID, quantity) endSale( ) makePayment(amount) Treat system as a black box

POS SYSTEM : Cashier enterItem(itemID, quantity)

POS SYSTEM : C : E : A : B Controller : D Domain Layer UI Layer : Cashier enterItem(itemID, quantity) : A : B Controller : D Technical Services Layer Domain Layer UI Layer Foundation Layer

Solution Assign the responsibility to a class representing one of the following choices: a façade controller represents the overall “system”, a “root object”, a device that the software is running within, or a major subsystem. Examples: MonopolyGame, ATMTerminal. a use case or session controller represents a use case scenario within which the system event occurs, often named <UseCaseName>Handler, <UseCaseName>Coordinator, or <UseCaseName>Session. Use the same controller class for all system events in the use case scenario. Example: ManageUsersHandler

EXAMPLE OF APPLICATION : System : Cashier makeNewSale( ) enterItem(itemID, quantity) endSale( ) makePayment(amount) What object should be the controller for the system events represented in this SSD?

The Controller pattern suggests the following possibilities: Façade controller Register OR POSSystem OR Use case controller ProcessSaleHandler / ProcessSaleSession Which should we choose?

If we choose Register as the controller for handling the system operation enterItem… POS SYSTEM : Cashier enterItem(itemID, quantity) … : Register : ? Controller Domain Layer UI Layer

Two examples of allocating system operations: Using one façade controller to handle all system operations: Register endSale() enterItem() makeNewSale() makePayment() … makeNewReturn() enterReturnItem()

Using a use case controller for each use case: ProcessSaleHandler HandleReturnsHandler endSale() enterItem() makeNewSale() makePayment() makeNewReturn() enterReturnItem() …

DISCUSSION Use the Controller pattern to guide in choosing a handler for system events. UI layer shouldn’t contain application logic. Thus, UI layer objects should not handle system events. They should delegate the task to objects in other layers (e.g. domain layer). Often, we will want to use the same controller class for all the system events of one use case. This will enable the controller to maintain information about the state of use case. Example: makePayment should come after endSale. Different controllers may be used for different use cases.

Façade controllers A façade controller represents the overall system, device or a subsystem. The idea is to choose some class name that suggests a cover (i.e. a façade) over the other layers of the application. It provides the main point of service calls from the UI layer down to other layers. Façade controllers are suitable when there are not “too many” system events.

Use case controllers If you choose use case controllers, you will have a different controller for each use case. Note that use case controllers are not domain objects. They are artificial constructs created to support the system. You should consider using use case controllers if using a façade controller leads to designs with low cohesion or high coupling. When there are many system events across different processes, a use case controller is a good choice. The handling of those events is distributed among separate classes. Furthermore, it allows keeping track of the progress of the current scenario.

EXAMPLE OF IMPLEMENTATION Design A Refer MyApplet_Design_A.java In this design, all system operations are handled in the MyApplet_Design_A class (a UI layer object). : MyApplet_Design_A : Cashier makeNewSale() POS System

EXAMPLE OF IMPLEMENTATION Design B (applies the Controller pattern) Refer MyApplet_Design_B.java In this design, the handling of system operations is delegated to the Register class (a non-UI layer object). : MyApplet_Design_B : Cashier makeNewSale() POS System : Register

THE ISSUE OF BLOATED CONTROLLERS Remember not to over-assign responsibilities to controllers. This leads to bloated controllers which have low cohesion. Guideline: Normally, a controller does not do much work itself. It coordinates or controls activities; work that needs to be done is delegated to other objects.

Indications of bloating: There is only a single controller class receiving all system events in the system, and there are many of them. The controller itself performs many of the tasks necessary to fulfill the system event, without delegating the work. A controller has many attributes, and it maintains significant information about the system or domain.

Two cures: Add more controllers Employ use case controllers instead of façade controllers. Design the controller so that it primarily delegates the fulfillment of each system operation responsibility to other objects.