SWE © Solomon Seifu 2010 1 ELABORATION. SWE © Solomon Seifu 2010 2 Lesson 12-3 Cohesion.

Slides:



Advertisements
Similar presentations
Quality of a Class Abstraction: Coupling & Cohesion Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
Advertisements

Communication between modules, cohesion and coupling
Design Concepts and Principles
Slide 7A.1 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005 Stephen R. Schach.
Lecture 9 Improving Software Design CSC301-Winter 2011 – University of Toronto – Department of Computer Science Hesam C. Esfahani
Introduction to Computers and Programming Lecture 11: Introduction to Methods Professor: Evan Korth New York University.
UHD::CS3320::CHAP61 INTRODUCTION TO OBJECTS Chapter 6.
Object-Oriented Metrics. Characteristics of OO ● Localization ● Encapsulation ● Information hiding ● Inheritence ● Object abstraction.
© Copyright 2011 John Wiley & Sons, Inc.
Introduction to Computers and Programming Introduction to Methods in Java.
Copyright W. Howden1 Lecture 6: Design Evaluation and Intro to OO Design Patterns.
Module: Definition ● A logical collection of related program entities ● Not necessarily a physical concept, e.g., file, function, class, package ● Often.
1 SOFTWARE DESIGN QUALITY COHESION and COUPLING (Part I)
1 Reusability and Portability Xiaojun Qi. 2 Reuse Concepts Reuse is the use of components of one product to facilitate the development of a different.
Jump to first page 1 System Design (Finalizing Design Specifications) Chapter 3d.
Developed by Reneta Barneva, SUNY Fredonia Component Level Design.
Software Issues Derived from Dr. Fawcett’s Slides Phil Pratt-Szeliga Fall 2009.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
CLEANROOM SOFTWARE ENGINEERING.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
CSE 303 – Software Design and Architecture
Coupling and Cohesion Pfleeger, S., Software Engineering Theory and Practice. Prentice Hall, 2001.
Coupling and Cohesion Source:
Design (1) Design involves decisions on how to deliver the agreed functionality to the users. Design involves development of a clear, unambiguous and consistent.
Program Design Simple Program Design Third Edition A Step-by-Step Approach 9.
SOFTWARE DESIGN (SWD) Instructor: Dr. Hany H. Ammar
Chapter 7: High Quality Routines By Raj Ramsaroop.
SOFTWARE DESIGN Design Concepts Design is a meaningful engineering representation of something that is to be built It can be traced to a customer’s requirements.
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 10 Use Case Design.
1 Introduction Modules  Most computer programs solve much larger problem than the examples in last sessions.  The problem is more manageable and easy.
Cohesion and Coupling CS 4311
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 12-5 Software Engineering Design Goals.
Programming Logic and Design Using Methods. 2 Objectives Review how to use a simple method with local variables and constants Create a method that requires.
Designing classes How to write classes in a way that they are easily understandable, maintainable and reusable 5.0.
Slide 7.1 Copyright © 2008 by The McGraw-Hill Companies, Inc. All rights reserved. Object-Oriented Software Engineering WCB/McGraw-Hill, 2008 Stephen R.
GRASP: Designing Objects with Responsibilities
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
Criteria Based Software Product Integration Architecture (2007) F. Tsui Kennesaw State University (Southern Polytechnic State University)
CS540 Software Design Lecture 3 & 4 1 Lecture 3 & 4: Modularity, Coupling, Cohesion and Abstraction Anita S. Malik Adapted from Schach.
Abstraction ADTs, Information Hiding and Encapsulation.
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (1/2)
Lecture 13 Law of Demeter. Cohesion Cohesion: the “glue” that holds a module together. Don’t do things that do not support a common goal Cohesion: the.
Jump to first page (C) 1998, Arun Lakhotia 1 Design Quality Metrics Arun Lakhotia University of Southwestern Louisiana Po Box Lafayette, LA 70504,
1 Introduction to Classes. 2 Terms and Concepts A class is... –The most important building block of any object- oriented system. –A description of a set.
Design and Planning Or: What’s the next thing we should do for our project?
Object-Oriented Design. 1 Objects and concerns Objects have a concern, meaning they have a purpose Not concerned as in worried All code should have a.
Refactoring Agile Development Project. Lecture roadmap Refactoring Some issues to address when coding.
Rohini Sharma Roll No. RA1809A01 Regd. No M.Tech.(CSE) Part Time 3 rd Semester.
From Use Cases to Implementation 1. Structural and Behavioral Aspects of Collaborations  Two aspects of Collaborations Structural – specifies the static.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
CSE 2341 Object Oriented Programming with C++ Note Set #4
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (1/2)
Programming Logic and Design Fifth Edition, Comprehensive Chapter 7 Using Methods.
Designing classes How to write classes in a way that they are easily understandable, maintainable and reusable 6.0.
Coupling and Cohesion Schach, S, R. Object-Oriented and Classical Software Engineering. McGraw-Hill, 2002.
Coupling and Cohesion Pfleeger, S., Software Engineering Theory and Practice. Prentice Hall, 2001.
7. Modular and structured design
Coupling and Cohesion 1.
Software Design Mr. Manoj Kumar Kar.
Software Maintenance PPT By :Dr. R. Mall.
Objects First with Java
Improving the Design “Can the design be better?”
CSSSPEC6 SOFTWARE DEVELOPMENT WITH QUALITY ASSURANCE
Need for the subject.
Programming Logic and Design Fourth Edition, Comprehensive
Software Design Lecture : 9.
Cohesion and Coupling.
Introduction Software maintenance:
DESIGN CONCEPTS AND PRINCIPLES
Presentation transcript:

SWE © Solomon Seifu ELABORATION

SWE © Solomon Seifu Lesson 12-3 Cohesion

SWE © Solomon Seifu SWE: Elaboration - Cohesion A measure of relatedness of the code in a given class A measure of how well the lines of source code within a module work together to provide a specific piece of functionality Cohesion is a measure of degree of how strongly a class focuses on its responsibilities

SWE © Solomon Seifu SWE: Elaboration - Cohesion (Cont.) High cohesion: This means that a class is designed to carry on a specific and precise task  Using high cohesion, methods are easier to understand, as they perform a single task Low cohesion: This means that a class is designed to carry on various tasks  Using low cohesion, methods are difficult to understand and maintain

SWE © Solomon Seifu 2010 SWE: Elaboration – Cohesion Types Coincidental cohesion Logical cohesion Temporal cohesion Procedural cohesion Communicational cohesion Functional cohesion Informational cohesion

SWE © Solomon Seifu SWE: Elaboration – Cohesion (Coincidental Cohesion) A module has coincidental cohesion if it performs multiple, completely unrelated operations Coincidental Cohesion is bad for the following reasons:  Such modules degrade the maintainability of the product, both corrective maintenance and enhancement  These modules are not reusable

SWE © Solomon Seifu SWE: Elaboration – Cohesion: (Coincidental Cohesion) (Cont.) A class exhibits coincidental cohesion if the tasks its methods perform are totally unrelated tasks class Coincidental { void initPrinter() {.. } double calcInterest() {.. } Date getDate() {... } }

SWE © Solomon Seifu SWE: Elaboration – Cohesion (Logical Cohesion) (Cont.) For example, the methods of the following class are related by the mathematical concept of area class Logical { double circleArea() {... } double rectangleArea() {... } double triangleArea() {... } } A class exhibits logical cohesion if its methods perform conceptually related tasks

SWE © Solomon Seifu SWE: Elaboration – Cohesion (Temporal Cohesion) (Cont.) For example, the methods of the following class are related by the device initialization concept, and they are all invoked at system boot time class Temporal { void initDisk() {... } void initPrinter() {... } void initMonitor() {... } } A class has temporal cohesion when it performs a series of operations related in time

SWE © Solomon Seifu SWE: Elaboration – Cohesion (Coincidental, Logical & Temporal Cohesions) One reason why coincidental, logical, and temporal cohesion are at the low end of our cohesion scale is because instances of such classes are unrelated to objects in the application domain. For example, suppose x and y are instances of the Temporal class:  Temporal x = new Temporal(), y = new Temporal();  How can we interpret x, and y? What do they represent? How are they different?

SWE © Solomon Seifu SWE: Elaboration – Cohesion (Procedural Cohesion) A class has procedural cohesion if it performs a series of operations related by the sequence of steps to be followed by the product (the result/outcome) In the Procedural class example, the outcome can be a cake or anything that is baked class Procedural { void addIngredients() {.. } void mix() {... } void bake() {... } }

SWE © Solomon Seifu SWE: Elaboration – Cohesion (Communicational Cohesion) A class has communicational cohesion if it performs a series of operations related by the sequence of steps to be followed by the product and if all the operations are performed on the same data E.g., UpdateRecordInDatabaseAndWriteIt ToTheAuditTrail(); CalculateNewTrajectoryAndSendItToThePrinter();

SWE © Solomon Seifu SWE: Elaboration – Cohesion (Functional Cohesion) A method that performs exactly one operation or achieves a single goal has functional cohesion E.g.,  getTempratureOfFurnace(),  ComputeOrbitalOfElectron(),  WriteToHardDrive(), and  CalculateSalesCommission()

SWE © Solomon Seifu SWE: Elaboration – Cohesion (Benefits of Functional Cohesion) A module with functional cohesion often can be reused because the one operation it performs frequently needs to be performed in other products A properly designed, thoroughly tested, and well- documented module with functional cohesion is a valuable (economic and technical) asset to any software organization and should be reused as often as possible

SWE © Solomon Seifu SWE: Elaboration – Cohesion (Benefits of Functional Cohesion) (Cont.) Maintenance is easier to perform on a module with functional cohesion Functional cohesion leads to fault isolation Because a module with functional cohesion performs only one operation, such a module generally is easier to understand than a module with lower cohesion. This understanding simplifies maintenance Functional cohesion also is valuable when a product has to be extended

SWE © Solomon Seifu SWE: Elaboration – Cohesion: Informational Cohesion (Cont.) A class exhibits informational cohesion if the tasks its methods perform operate on the same information or data In object oriented programming this information would be the information contained in the instance variables of an object Only f 1, … f n have access to the shared data. Similar to a class in OO programming language. f 1, … f n are functionally cohesive Shared Data f1f2fn …

SWE © Solomon Seifu SWE: Elaboration – Cohesion (Informational Cohesion) (Cont.) For example, the Informational class exhibits informational cohesion because its methods all work on the same information:  the speed, and  altitude of some Airplane object class Informational { private double speed; private double altitude; void takeoff() {..} void fly() {..} void land() {..} }

SWE © Solomon Seifu 2010 SWE: Elaboration – Cohesion (Seven Levels [From the Best to the Worst]) Cohesion Informational I Functional Communicational Procedural Temporal Logical Coincidental 18 Best Worst

SWE © Solomon Seifu 2010 SWE: Elaboration – Cohesion (Wholeness) Cohesion is a measure of how strongly- related is the functionality expressed by the source code of a software module Functional & informational cohesion are the best form of cohesion Coincidental and logical cohesion are the worst forms of cohesion and must be avoided