OO Design Roshan Chitrakar. Analysis to Design Do the RIGHT thing Do the RIGHT thing Requirement Analysis Requirement Analysis Domain Modeling with addition.

Slides:



Advertisements
Similar presentations
GRASP: Designing Objects with Responsibilities
Advertisements

Object Design Examples with GRASP
GRASP Patterns M Taimoor Khan
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:
© 2005 Prentice Hall8-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
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.
Low Coupling High Cohesion
NJIT 1 GRASP: Designing Objects with Responsibilities Chapter 17 Applying UML and Patterns Craig Larman.
Object-Oriented Analysis and Design
GRASP : Designing Objects with Responsibilities
October 20, 2005Architectural Design, ECEN Architectural Design Architecture Business Cycle Design for Maintainability ECEN 5543 / CSCI 5548 SW Eng.
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
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.
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 )
Chapter 7: Object Design Examples with GRASP. Objective Design use case realizations. Apply GRASP to assign responsibilities to classes. Apply UML to.
Requirements To Design--Iteratively Chapter 12 Applying UML and Patterns Craig Larman.
INFO 620Lecture #61 Information Systems Analysis and Design More Class Modeling; Patterns INFO 620 Glenn Booker.
BTS430 Systems Analysis and Design using UML Design Patterns.
GRASP: Designing Objects With Responsibilities Chapter 17 Applying UML and Patterns -Craig Larman.
GRASP: Designing Objects With Responsibilities
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
Object-Oriented Design Part 2
Next Gen POS Example GRASP again. Same Patterns Different Example!
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.
TK2023 Object-Oriented Software Engineering CHAPTER 12 Introduction to Responsibility-Driven Design.
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
References: Applying UML and patterns Craig Larman
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.
OO Methodology Elaboration Phase Iteration 1- Part 2.
TK2023 Object-Oriented Software Engineering CHAPTER 13d GRASP Patterns: High Cohesion.
TK2023 Object-Oriented Software Engineering
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
GRASP (General Responsibility Assignment Software Patterns)
CONTENTS Object-Oriented Modeling Using UML
Next Gen POS Example GRASP again.
Object Oriented System Design Responsibilities
Presentation transcript:

OO Design Roshan Chitrakar

Analysis to Design Do the RIGHT thing Do the RIGHT thing Requirement Analysis Requirement Analysis Domain Modeling with addition of attributes and associations Domain Modeling with addition of attributes and associations Use Case Modeling (Behavioral modeling) Use Case Modeling (Behavioral modeling) Requisite Pro and Use case diagrams Requisite Pro and Use case diagrams Do the thing RIGHT Do the thing RIGHT Responsibility assignment Responsibility assignment Object Design Object Design Design Class diagrams Design Class diagrams Determining visibility Determining visibility Interaction diagrams (Sequence diagrams & Collaboration diagrams, Class diagram) Interaction diagrams (Sequence diagrams & Collaboration diagrams, Class diagram)

OO Design: Introduction A logical solution based on OO paradigm is developed A logical solution based on OO paradigm is developed Constitutes a design model Constitutes a design model Creation of Interaction diagrams (collaboration among objects and/or sequence of messages) Creation of Interaction diagrams (collaboration among objects and/or sequence of messages) Class diagrams are drawn in parallel with or after the interaction diagrams Class diagrams are drawn in parallel with or after the interaction diagrams

GRASP Fundamental principles of Object design are: - Fundamental principles of Object design are: - Responsibility assignment and Responsibility assignment and Design patterns Design patterns GRASP (General Responsibilities Assignment Software Patterns) describe the principles of object design and responsibility assignment, expressed as patterns. GRASP (General Responsibilities Assignment Software Patterns) describe the principles of object design and responsibility assignment, expressed as patterns.

Responsibility It is a contract or obligation of a classifier It is a contract or obligation of a classifier It is assigned to classes during object design It is assigned to classes during object design Type of Responsibilities Type of Responsibilities Knowing (e.g. “a Sale is responsible for knowing its total”) Knowing (e.g. “a Sale is responsible for knowing its total”) about private encapsulated data about private encapsulated data about related objects about related objects about things it can derive or calculate about things it can derive or calculate Doing (e.g. “a Sale is responsible for creating SalesLineItems”) Doing (e.g. “a Sale is responsible for creating SalesLineItems”) something itself something itself initiating action in other objects initiating action in other objects controlling and coordinating activities in other objects controlling and coordinating activities in other objects

Methods Responsibilities are translated into methods Responsibilities are translated into methods Depending upon the granularity, several methods are implemented to fulfill the responsibilities Depending upon the granularity, several methods are implemented to fulfill the responsibilities Methods either act alone or collaboratively Methods either act alone or collaboratively Both responsibilities and methods are reflected in interaction diagrams Both responsibilities and methods are reflected in interaction diagrams

Responsibility & Methods in Interaction Diagram makePayment(cashTendered) create(cashTendered) : Sale : Payment Responsibility: To create Payments

Patterns A pattern is a named problem/solution pair that can be applied in new context, with advice on how to apply it in novel situation and discussion of its trade-offs. e.g. Pattern Name: Information Expert Solution: Assign a responsibility to the class that has the information needed to fulfill it. Problem It Solves: What is a basic principle by which to assign responsibilities to objects. A pattern is a named problem/solution pair that can be applied in new context, with advice on how to apply it in novel situation and discussion of its trade-offs. e.g. Pattern Name: Information Expert Solution: Assign a responsibility to the class that has the information needed to fulfill it. Problem It Solves: What is a basic principle by which to assign responsibilities to objects.

The First Five GRAS Patterns They are: - They are: - 1. Information Expert (or Expert) 2. Creator 3. High Cohesion 4. Low Coupling 5. Controller They cover very basic, common and fundamental design issues They cover very basic, common and fundamental design issues

Information Expert It guides that objects do things related to the information they have. It guides that objects do things related to the information they have. It is a class that has information necessary to fulfill the responsibility It is a class that has information necessary to fulfill the responsibility There may have partial information experts who will collaborate for the responsibility There may have partial information experts who will collaborate for the responsibility Design Class Responsibility Sale Knows sale total SalesLineItem Knows line item subtotal ProductSpecification Knows product price

Expert Illustration : To find out the grand total Domain model showing association of Sale

Expert Illustration : To find out the grand total Knowing Line Item sub total and knowing product price in order to get the grand total. Responsibilities are being added to both interaction and Class diagrams also. More than one class can act as information expert. They collaborate by passing messages.

Expert: Pro and Cons Advantages: - Advantages: - Encapsulation is maintained Encapsulation is maintained Behavior is distributed across the classes Behavior is distributed across the classes Disadvantages: - Disadvantages: - Leads to problems of coupling, cohesion and duplication Leads to problems of coupling, cohesion and duplication

Creator It guides assigning responsibilities related to the creation of objects It guides assigning responsibilities related to the creation of objects The concept of aggregation is the basic guiding principle of the Creator. The concept of aggregation is the basic guiding principle of the Creator. It suggests that the enclosing container or recorder class is a good candidate for the responsibility It suggests that the enclosing container or recorder class is a good candidate for the responsibility

Creator Illustration : Creating a Sales Line Item Sale Domain

Creator Illustration : Creating a Sales Line Item

Creator: Pro and Cons Benefits: - Benefits: - Low coupling is supported i.e lower maintenance dependence and higher possibility of reuse. Low coupling is supported i.e lower maintenance dependence and higher possibility of reuse. Contraindications: - Contraindications: - In special cases, all creations are delegated to a helper class called Factory. (Which is against the principle of Creator) In special cases, all creations are delegated to a helper class called Factory. (Which is against the principle of Creator)

Low Coupling It suggests assigning a responsibilities to classes such that their placement does not produce negative results. It suggests assigning a responsibilities to classes such that their placement does not produce negative results. It recommends designs of classes to be more independent and hence reduce the impacts of change. It recommends designs of classes to be more independent and hence reduce the impacts of change. No absolute measure of low/high coupling, designer has to assess it so that negative results would not occur. No absolute measure of low/high coupling, designer has to assess it so that negative results would not occur.

Low Coupling Illustration : Creating a Payment PaymentRegisterSale Creator pattern suggests Register as a candidate for creating the Payment. Coupling of Register class to the knowledge of Payment class

Low Coupling Illustration : Creating a Payment An alternate solution: Coupling of Sale class with the Payment class Sale creates the Payment; does not increase the coupling

High Cohesion “High functional cohesion exists when the elements of a component (e.g. a class) all work together to provide some well-bounded behavior”- Booch “High functional cohesion exists when the elements of a component (e.g. a class) all work together to provide some well-bounded behavior”- Booch High Cohesion has fewer methods, with highly related functionality, collaborates with other objects to share the effort. High Cohesion has fewer methods, with highly related functionality, collaborates with other objects to share the effort. High Cohesion pattern has real world analogy or delegating the too much work. High Cohesion pattern has real world analogy or delegating the too much work.

High Cohesion Illustration : Creating a Payment Register creates the Payment by taking the work by itself: Low cohesion

High Cohesion Illustration : Creating a Payment Register delegates the work to Sale : Low cohesion

High Cohesion: Pro and Cons Advantages: - Advantages: - Maintenance and enhancement is simplified Maintenance and enhancement is simplified Low coupling is often supported Low coupling is often supported Reuse is increased. Reuse is increased. Disadvantages: - Disadvantages: - Distributed servers take more overhead and pay reduced performance Distributed servers take more overhead and pay reduced performance For only one person to maintain and support the component, it is difficult. For only one person to maintain and support the component, it is difficult.

Controller It provides guidance for handlers for external inputs / events messages or signals that system receives. It provides guidance for handlers for external inputs / events messages or signals that system receives. It delegates, coordinates and controls the work to other objects: does not do the actual work. It delegates, coordinates and controls the work to other objects: does not do the actual work. The System class made during the analysis phase, is now taken care of by Controller class. The System class made during the analysis phase, is now taken care of by Controller class.

System Class to Controller Class Register acts as the single Controller Class Two handlers act like Controllers

Controller Illustration : enterItem()

Possible handlers are: - : Register enterItem(id,quantity) : ProcessSaleHandler enterItem(id,quantity)

Controller: Pro and Cons Increased potential for reuse Increased potential for reuse Pluggable interface (i.e. application logic is not handled in the interface layer) Pluggable interface (i.e. application logic is not handled in the interface layer) It guarantees that system operations within a use case occur in a legal sequence (It is possible if the same controller is used throughout the use case) It guarantees that system operations within a use case occur in a legal sequence (It is possible if the same controller is used throughout the use case)