Cohesion and Coupling.

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
1 Software Design Introduction  The chapter will address the following questions:  How do you factor a program into manageable program modules that can.
1 SOFTWARE DESIGN QUALITY COHESION and COUPLING (Part II)
Lecture 9 Improving Software Design CSC301-Winter 2011 – University of Toronto – Department of Computer Science Hesam C. Esfahani
What is Software Design?  Introduction  Software design consists of two components, modular design and packaging.  Modular design is the decomposition.
Copyright Irwin/McGraw-Hill Software Design Prepared by Kevin C. Dittman for Systems Analysis & Design Methods 4ed by J. L. Whitten & L. D. Bentley.
UHD::CS3320::CHAP61 INTRODUCTION TO OBJECTS Chapter 6.
© Copyright 2011 John Wiley & Sons, Inc.
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)
Jump to first page 1 System Design (Finalizing Design Specifications) Chapter 3d.
Criteria for good design. aim to appreciate the proper and improper uses of inheritance and appreciate the concepts of coupling and cohesion.
Developed by Reneta Barneva, SUNY Fredonia Component Level Design.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Coupling and Cohesion Pfleeger, S., Software Engineering Theory and Practice. Prentice Hall, 2001.
Coupling and Cohesion Source:
Program Design Simple Program Design Third Edition A Step-by-Step Approach 9.
Software Design Designing the overall structure (architecture) of a software system Designing small pieces of computation Designing non-automated processes.
SOFTWARE DESIGN (SWD) Instructor: Dr. Hany H. Ammar
1 Software Design Reference: Software Engineering, by Ian Sommerville, Ch. 12 & 13, 5 th edition and Ch. 10, 6 th edition.
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.
1 Software Design Overview Reference: Software Engineering, by Ian Sommerville, Ch. 12 & 13.
Concepts of Software Quality Yonglei Tao 1. Software Quality Attributes  Reliability  correctness, completeness, consistency, robustness  Testability.
Cohesion and Coupling CS 4311
Systems analysis and design, 6th edition Dennis, wixom, and roth
System Implementation
Coupling & Cohesion CMSC 201- Fall '11. Vocabulary Routine- A programming unit that performs a task, such as a function, procedure, method, or main class.
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.
Coupling Cohesion Chandan R. Rupakheti Steve Chenoweth (Chapter 18)
CCSB223/SAD/CHAPTER131 Chapter 13 Designing the System Internals.
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter.
Jump to first page (C) 1998, Arun Lakhotia 1 Design Quality Metrics Arun Lakhotia University of Southwestern Louisiana Po Box Lafayette, LA 70504,
CHAPTER 3 MODELING COMPONENT-LEVEL DESIGN.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Key Principles of Software Architecture and Design (II) adapted from Dave Penny’s.
Week 6: Software Design HNDIT Software Engineering Software Design Learning Outcomes  Understand the activities involved in the Design process.
Rohini Sharma Roll No. RA1809A01 Regd. No M.Tech.(CSE) Part Time 3 rd Semester.
Systems Development Lifecycle
Slide 1 Good Methods. Slide 2 Cohesion and Coupling l For structured design These software metrics were used extensively Proven to be effective l For.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
SOFTWARE DESIGN & SOFTWARE ENGINEERING Software design is a process in which data, program structure, interface and their details are represented by well.
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.
Further Modularization, Cohesion, and Coupling. Simple Program Design, Fourth Edition Chapter 9 2 Objectives In this chapter you will be able to: Further.
Unit - 3 OBJECT ORIENTED DESIGN PROCESS AND AXIOMS
7. Modular and structured design
Metrics of Software Quality
Coupling and Cohesion Rajni Bhalla.
Basic Concepts in Software Design
Coupling and Cohesion 1.
System Design and Modeling
Basic Concepts in Software Design
Software Design Mr. Manoj Kumar Kar.
Software Engineering: A Practitioner’s Approach, 6/e Chapter 11 Component-Level Design copyright © 1996, 2001, 2005 R.S. Pressman & Associates, Inc.
Systems Analysis and Design
Not what first comes to mind
Class and Method Design
Coupling and Cohesion By Bonnie Ngu.
Cohesion and Coupling Chapter 5, Pfleeger 01/01/10.
Software Design Designing the overall structure (architecture) of a software system Designing small pieces of computation Designing non-automated processes.
Improving the Design “Can the design be better?”
Programming Logic and Design Fourth Edition, Comprehensive
CS223: Software Engineering
Software Design CMSC 345, Version 1/11.
Programming Logic and Design Fourth Edition, Comprehensive
Software Design Lecture : 9.
Software Design Lecture : 10
Communication between modules, cohesion and coupling
Design Module view What module should the system and which have to be developed . It determines the module structure of components.
DESIGN CONCEPTS AND PRINCIPLES
Presentation transcript:

Cohesion and Coupling

Cohesion Cohesion refers to the degree to which the elements of a module belong together.

Types of Cohesion Coincidental cohesion (worst): the parts of a component are not related but simply bundled into a single component. Harder to understand and not reusable.  (e.g. a “Utilities” class). Logical association: similar functions such as input, error handling, etc. put together. Functions fall in same logical class (like input). May pass a flag to determine which ones executed. interface difficult to understand. Code for more than one function may be intertwined, leading to severe maintenance problems. Difficult to reuse. Temporal cohesion: Temporal cohesion is when parts of a module are grouped by when they are processed - the parts are processed at a particular time in program execution ( e.g start up or shut down, are brought together. Initialization, clean up. )Functions weakly related to one another, but more strongly related to functions in other modules so may need to change lots of modules when do maintenance. Procedural cohesion: (e.g. a function which checks file permissions and then opens the file).

Communicational cohesion: operate on same input data or produce same output data. May be performing more than one function. Generally acceptable if alternate structures with higher cohesion cannot be easily identified. Still problems with reusability. Sequential cohesion: output from one part serves as input for another part. May contain several functions or parts of different functions. Functional cohesion  (best): Functional cohesion is when parts of a module are grouped because they all contribute to a single well-defined task of the module. Each part necessary for execution of a single function. e.g., compute square root or sort the array. first two types of cohesion are inferior; communicational and sequential cohesion are very good; and functional cohesion is superior.

Coupling Coupling is a measure that defines the level of inter-dependability among modules of a program. It tells at what level the modules interfere and interact with each other. The lower the coupling, the better the program.

Types of Coupling for procedural languages Levels of coupling, namely – Content coupling  (high) -  (also known as Pathological coupling) when one module modifies or relies on the internal workings of another module (e.g., accessing local data of another module). In this situation, a change in the way the second module produces data (location, type, timing) might also require a change in the dependent module. Common coupling- When multiple modules have read and write access to some global data, it is called common or global coupling. Changing the shared resource might imply changing all the modules using it. External coupling- occurs when two modules share an externally imposed data format, communication protocol, or device interface. This is basically related to the communication to external tools and devices. Control coupling- Two modules are called control-coupled if one of them decides the function of the other module or changes its flow of execution or Control coupling is one module controlling the flow of another, by passing it information on what to do (e.g., passing a what-to-do flag).

Stamp coupling (Data-structured coupling)- When multiple modules share common data structure and work on different part of it, it is called stamp coupling  (e.g., passing a whole record to a function that only needs one field of it). Data coupling- Data coupling is when two modules interact with each other by means of passing data (as parameter). If a module passes data structure as parameter, then the receiving module should use all its components.  (e.g., passing an integer to a function that computes a square root). Message coupling (low)-This is the loosest type of coupling. It can be achieved by state decentralization (as in objects) and component communication is done via parameters or message passing.

Coupling in Object-oriented programming Subclass Coupling- Describes the relationship between a child and its parent. The child is connected to its parent, but the parent is not connected to the child. Temporal coupling- When two actions are bundled together into one module just because they happen to occur at the same time. Ideally, no coupling is considered to be the best.