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-Oriented Analysis and Design
Object Design Examples with GRASP
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.
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:
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
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 Software Engineering Practical Software Development using UML and Java Design Patterns Sources: Chapter 6: Using Design Patterns, and Chapter.
Object-Oriented Analysis and Design
Software Design Yashvardhan Sharma.
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.
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.
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.
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)
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
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.
BTS430 Systems Analysis and Design using UML Domain Model—Part 2: Associations and Attributes.
Object-Oriented Analysis and Design Mar 9, 2008.
Fall 2009ACS-3913 Ron McFadyen1 Use Case Realizations with GRASP Patterns “The assignment of responsibilities and design of collaborations are very important.
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.
BTS430 Systems Analysis and Design using UML Domain Model—Part 2: Associations and Attributes.
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 Chapter 9: Operation Contracts Chapter 13 in Applying UML and Patterns Book.
Use-Case Model: Adding Detail with Operation Contracts.
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.
OO Methodology Elaboration Phase Iteration 1- Part 2.
TK2023 Object-Oriented Software Engineering CHAPTER 13d GRASP Patterns: High Cohesion.
Ch 17: Use Case Realizations with GRASP Patterns
TK2023 Object-Oriented Software Engineering
Object Design Examples with GRASP
TK2023 Object-Oriented Software Engineering
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
GRASP : Designing Objects with Responsibilities
GRASP Design Patterns: Designing Objects with Responsibilities
Chapter 11: Class Diagram
CONTENTS Object-Oriented Modeling Using UML
Implementation Model: Mapping Designs to Code
Operation Contracts Ch. 11.
Next Gen POS Example GRASP again.
Chapter 11: Class Diagram
Design Model: Creating Design Class Diagrams
Presentation transcript:

TK2023 Object-Oriented Software Engineering CHAPTER 13a GRASP Patterns: Creator

GRASP PATTERNS: CREATOR Problem Who should be responsible for creating a new instance of some class? Solution Assign class B the responsibility to create an instance of class A if one of these is true: B “contains” or compositely aggregates A B records A B closely uses A B has the initializing data for A that will be passed to A when it is created. B is said to be a creator of A objects.

EXAMPLE OF APPLICATION In the POS application, when the Cashier enters a new item, a line item needs to be created and associated with the current sale. Referring to the domain model, Sale time 1 Contains 1 .. * Product Sales Description * 1 LineItem Described - by description quantity price itemID

We have a design problem… who should be responsible for creating a SalesLineItem instance? The Creator pattern suggests that Sale is a good candidate to be assigned that responsibility as a Sale contains many SalesLineItem objects (according to our domain model).

One way to realize this is to define a method in the Sale class which will carry out that responsibility. Let’s call this method makeLineItem() (for now, we’ll ignore its parameters). : Register Sale makeLineItem() SalesLineItem {new} SalesLineItem()

DISCUSSION A very common task in object design is assigning responsibilities related to the creation of objects. The Creator pattern provides guidance for doing this. The basic intent of the Creator pattern is to find a creator that needs to be connected to the created object in any event. Choosing that object as the creator supports low coupling.

Register SalesLineItem Sale : Register : Sale makeLineItem() SalesLineItem {new} Register Sale SalesLineItem

Consider the following realization: Register : Sale SalesLineItem() s1 : SalesLineItem {new} addLineItem(s1) Register Sale SalesLineItem Coupling is increased!

Creator suggests that the enclosing container or recorder class is a good candidate for the responsibility of creating the thing contained or recorded. Remember that the Creator pattern only provides a guideline. Use your judgement in deciding whether or not to apply the pattern.

Sometimes a creator can be identified by looking for the class that has the initializing data that will be passed in during creation. For example, supposing a Payment object needs to be initialized to the total of the current Sale. Since Sale knows the total, it is a candidate creator of the Payment. : Register Sale makePayment() Payment {new} Payment(total)