TK2023 Object-Oriented Software Engineering CHAPTER 13d GRASP Patterns: High Cohesion.

Slides:



Advertisements
Similar presentations
GRASP: Designing Objects with Responsibilities
Advertisements

Object-Oriented Analysis and Design CHAPTER 17, 25: GRASP PATTERNS 1.
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:
NJIT More GRASP Patterns Chapter 22 Applying UML and Patterns Craig Larman Prepared By: Krishnendu Banerjee.
February Ron McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m.
Low Coupling High Cohesion
NJIT 1 GRASP: Designing Objects with Responsibilities Chapter 17 Applying UML and Patterns Craig Larman.
Object-Oriented Analysis and Design
Software Design Yashvardhan Sharma.
GRASP : Designing Objects with Responsibilities
October 20, 2005Architectural Design, ECEN Architectural Design Architecture Business Cycle Design for Maintainability ECEN 5543 / CSCI 5548 SW Eng.
Design Patterns and Responsibility Assignment CMPT 371 Fall 2004 J.W. Benham.
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 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 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.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
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 )
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.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
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.
CS212: Object Oriented Analysis and Design GRASP Design Principles.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
Object-Oriented Design Principles and Patterns. © 2005, James R. Vallino2 How Do You Design? What principles guide you when you create a design? What.
D ESIGN P ATTERNS Weslei A. de T. Marinho. T ALK O UTLINE Pattern Definition GRASP Patterns GoF Patterns GoF Patterns Classification Creational Patterns.
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.
Article Summary of The Structural Complexity of Software: An Experimental Test By Darcy, Kemerer, Slaughter and Tomayko In IEEE Transactions of Software.
1 By Rick Mercer with help from Object-Oriented Design Heuristics, Arthur Riel Coupling / Cohesion.
OO Design Roshan Chitrakar. Analysis to Design Do the RIGHT thing Do the RIGHT thing Requirement Analysis Requirement Analysis Domain Modeling with addition.
Copyright © Craig Larman All Rights Reserved COMP-350 Object-Oriented Analysis and Design GRASP: Designing Objects with Responsibilities Reference:
GRASP: Designing Objects With Responsibilities
References: Applying UML and patterns Craig Larman
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.
GRASP: More Patterns for Assigning Responsibilities Presented By Dr. Shazzad Hosain.
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.
TK2023 Object-Oriented Software Engineering
Elaboration: Iteration 2. Elaboration: Iteration 2 Basics Iteration 1 ends with : All the software has been tested: The idea in the UP is to do early,
Subsystems 02/ 09. Subsystem A component Encapsulates data Bundles operations with information.
Object Design Examples with GRASP
GRASP – Designing Objects with Responsibilities
TK2023 Object-Oriented Software Engineering
GoF Patterns (GoF) popo.
TK2023 Object-Oriented Software Engineering
Chapter 12: Collaboration Diagram - PART2
Conception OBJET GRASP Patterns
Introduction to Design 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
Introduction to Design Patterns Part 1
Next Gen POS Example GRASP again.
Object Oriented System Design Responsibilities
Presentation transcript:

TK2023 Object-Oriented Software Engineering CHAPTER 13d GRASP Patterns: High Cohesion

GRASP PATTERNS: HIGH COHESION Problem How to keep objects focused, understandable, and manageable, and as a side effect, support Low Coupling?

In object design, cohesion is a measure of how strongly related and focused the responsibilities of an element are. An element with highly related responsibilities that does not do a tremendous amount of work has high cohesion. The element can be a class, subsystem, and so on.

A class with low cohesion does many unrelated things or does too much work. Classes with low cohesion are undesirable because they are  hard to understand  hard to reuse  hard to maintain  delicate; constantly affected by change Low cohesion classes usually represent a very “large grain” of abstraction or have been assigned responsibilities that should have been delegated to other objects.

Solution Assign a responsibility so that cohesion remains high. Use this principle to evaluate alternatives.

EXAMPLE OF APPLICATION In the POS application, when the Cashier enters a payment, a Payment object needs to be created and associated with the current Sale. Who should be responsible for creating a Payment instance and associate it with Sale ?

The Creator pattern suggests assigning that responsibility to Register. : Register p : Payment : Sale 1. makePayment( ) 1.1. Payment( ) 1.2. addPayment(p) {new} DESIGN 1

If we continue to make the Register class responsible for doing some or most of the work related to more and more system operations, it will become increasingly burdened with tasks and become incohesive.

The following design delegates the responsibility for creating the Payment instance to Sale. : Register : Payment : Sale 1. makePayment( ) 1.1. makePayment( ) Payment( ) {new} DESIGN 2

In Design 1, the Register class is less cohesive. Design 2 supports not only high cohesion but also low coupling. Thus, it is more desirable than Design 1.

DISCUSSION Like Low Coupling, High Cohesion is an evaluative principle that is applied while evaluating design decisions. As a rule of thumb, a class with high cohesion has a relatively small number of methods, with highly related functionality, and does not do too much work. It collaborates with other objects to share the effort if the task is large.

Real-world analogy: A person who takes on too many unrelated responsibilities (ones that should be delegated to others) becomes an ineffective person.

CONTRAINDICATIONS There are certain cases where lower cohesion is accepted. Examples:  Grouping of responsibilities or code into one class or component to simplify maintenance by one person.  Creating fewer and larger, less cohesive server objects to reduce remote calls and improve performance.

BENEFITS Benefits of High Cohesion:  Increases clarity and ease of comprehension  Simplifies maintenance and enhancements  Often supports low coupling  Increases reuse of fine-grained, highly related functionality because a cohesive class can be used for a very specific purpose.