Further Modularization, Cohesion, and Coupling. Simple Program Design, Fourth Edition Chapter 9 2 Objectives In this chapter you will be able to: Further.

Slides:



Advertisements
Similar presentations
Lecture 6: Software Design (Part I)
Advertisements

Quality of a Class Abstraction: Coupling & Cohesion Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
Chapter 3: Modules, Hierarchy Charts, and Documentation
Structured Design. 2 Design Quality – Simplicity “There are two ways of constructing a software design: One is to make it so simple that there are obviously.
Chapter 3: Modularization
Chapter 2: Modularization
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.
Programming Logic and Design Fourth Edition, Introductory
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.
© Copyright 2011 John Wiley & Sons, Inc.
Module Cohesion and Coupling Lecture 10. How to determine a good module? Cohesion: a measure of the internal strenght of a module – how closely the elements.
Jump to first page 1 System Design (Finalizing Design Specifications) Chapter 3d.
PowerPoint Presentation for Dennis & Haley Wixom, Systems Analysis and Design Copyright 2000 © John Wiley & Sons, Inc. All rights reserved. Slide 1 Key.
Modules, Hierarchy Charts, and Documentation
Pseudocode.
General Algorithms for Common Business Problems
Chapter 1 Program Design
Pseudocode.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
Systems Analysis and Design
Structured COBOL Programming, Stern & Stern, 9th edition
Simple Program Design Third Edition A Step-by-Step Approach
Coupling and Cohesion Pfleeger, S., Software Engineering Theory and Practice. Prentice Hall, 2001.
Program Design Simple Program Design Third Edition A Step-by-Step Approach 9.
First Steps in Modularization Simple Program Design Third Edition A Step-by-Step Approach 8.
1 Software Design Reference: Software Engineering, by Ian Sommerville, Ch. 12 & 13, 5 th edition and Ch. 10, 6 th edition.
Array Processing.
1 Software Design Overview Reference: Software Engineering, by Ian Sommerville, Ch. 12 & 13.
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
Developing an Algorithm
Cohesion and Coupling CS 4311
Systems analysis and design, 6th edition Dennis, wixom, and roth
System Implementation
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
Coupling Cohesion Chandan R. Rupakheti Steve Chenoweth (Chapter 18)
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
General Algorithms for Common Business Problems Simple Program Design Third Edition A Step-by-Step Approach 10.
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
Pseudocode Algorithms Using Sequence, Selection, and Repetition
Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
CCSB223/SAD/CHAPTER131 Chapter 13 Designing the System Internals.
Developing an Algorithm. Simple Program Design, Fourth Edition Chapter 3 2 Objectives In this chapter you will be able to: Introduce methods of analyzing.
Chapter 8 First steps in modularisation. Objectives To introduce modularisation as a means of dividing a problem into subtasks To present hierarchy charts.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Systems Design.  Application Design  User Interface Design  Database Design.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
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.
7. Modular and structured design
Coupling and Cohesion Rajni Bhalla.
Basic Concepts in Software Design
Coupling and Cohesion 1.
Basic Concepts in Software Design
Software Design Mr. Manoj Kumar Kar.
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?”
Software Design CMSC 345, Version 1/11.
Programming Logic and Design Fourth Edition, Comprehensive
Software Design Lecture : 9.
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.
Cohesion and Coupling.
Presentation transcript:

Further Modularization, Cohesion, and Coupling

Simple Program Design, Fourth Edition Chapter 9 2 Objectives In this chapter you will be able to: Further develop modularization using a more complex problem Introduce cohesion as a measure of the internal strength of a module Introduce coupling as a measure of the extent of information interchange between modules

Simple Program Design, Fourth Edition Chapter Define the problem by dividing it into its three components: input, output, and processing 2.Group the activities into subtasks or functions to determine the modules that will make up the program 3.Construct a hierarchy chart to illustrate the modules and their relationship to each other 4.Establish the logic of the mainline of the algorithm in pseudocode 5.Develop the pseudocode for each successive module in the hierarchy chart 6.Desk check the solution algorithm Steps in Modularization

Simple Program Design, Fourth Edition Chapter 9 4 Examine the problem statement and the problem definition along with the list of activities grouped into modules, and examine the constructed hierarchy chart Then examine the code illustrated for the logic of the mainline of the algorithm in pseudocode along with the pseudocode for each successive module in the hierarchy chart as shown on pages 140 through 143 of the textbook Example 9.1 Calculate Vehicle Registration Costs

Simple Program Design, Fourth Edition Chapter 9 5 Module Cohesion Programmers often need guidance in determining what makes a good module Common queries include: ‘How big should a module be?’, ‘Is this module too small?’ and ‘Should I put all the read statements in one module?’ Cohesion is a measure of the internal strength of a module

Simple Program Design, Fourth Edition Chapter 9 6 Coincidental Cohesion The weakest form of cohesion a module can have is coincidental cohesion It occurs when elements are collected into a module simply because they happen to fall together Examine the pseudocode example of a module that has coincidental cohesion illustrated on page 144 of the textbook

Simple Program Design, Fourth Edition Chapter 9 7 Coincidental Cohesion Coincidental cohesion typically used to occur as a result of the following conditions: –An existing program may have been arbitrarily segmented into smaller modules because of hardware constrictions on the operation of the program –Existing modules may have been arbitrarily subdivided to conform to a badly considered programming standard –A number of existing modules may have been combined into one module either to reduce the number of modules in a program or to increase the number of statements in a module to a particular minimum number

Simple Program Design, Fourth Edition Chapter 9 8 Logical Cohesion Logical cohesion occurs when the elements of a module are grouped together according to a certain class of activity An example might be a module that performs all the read statements for three different files: a sort of ‘Read_all_files’ module In such a case, the calling module would need to indicate which of the three files it required the called module to read, by sending a parameter Examine the pseudocode example to see what a ‘Read_all_files’ module might look like as shown on page 145 of the text

Simple Program Design, Fourth Edition Chapter 9 9 Temporal Cohesion Temporal cohesion occurs when the elements of a module are grouped together because they are related by time Typical examples are initialization and finalization modules, where elements are placed together because they perform certain housekeeping functions at the beginning or end of a program

Simple Program Design, Fourth Edition Chapter 9 10 Procedural Cohesion Procedural cohesion occurs when the elements of a module are related because they operate according to a particular procedure A typical example of a procedurally cohesive module is the mainline of a program The elements of a mainline are grouped together because of a particular procedural order The weakness of procedurally cohesive modules is that they cut across functional boundaries as illustrated in the code on page 146 of the text

Simple Program Design, Fourth Edition Chapter 9 11 Communicational Cohesion Communicational cohesion occurs when the elements of a module are grouped together because they all operate on the same piece of data Communicationally cohesive modules are commonly found in business applications because of the close relationship of a business program to the data it is processing The weakness of a communicationally cohesive module lies in the fact that usually a combination of processing for a particular piece of data is performed, as in the pseudocode example shown on page 147 of the textbook

Simple Program Design, Fourth Edition Chapter 9 12 Sequential Cohesion Sequential cohesion occurs when a module contains elements that depend on the processing of previous elements A sequentially cohesive module is like an assembly line: a series of sequential steps that perform successive transformations of data Sequential cohesion is stronger than communicational cohesion because it is more problem-oriented Its weakness lies only in the fact that the module may perform multiple functions or fragments of functions Examine the pseudocode on page 148 of the text which shows an example of sequential cohesion

Simple Program Design, Fourth Edition Chapter 9 13 Functional Cohesion Functional cohesion occurs when all the elements of a module contribute to the performance of a single specific task The module can be easily named by a single verb followed by a two-word object Mathematically oriented modules are a good example of functional cohesion A pseudocode example of a functionally cohesive module is the module Calculate_sales_tax depicted on page 148 of the textbook

Simple Program Design, Fourth Edition Chapter 9 14 Summary of Cohesion Levels When designing the structure of an algorithm, you should try to form modules that have a single problem-related function If functional cohesion is achieved, the modules will be more independent, easier to read and understand, and more maintainable than modules with lesser cohesion Your prime consideration is to produce modules and programs that are easy to understand and modify

Simple Program Design, Fourth Edition Chapter 9 15 Module Coupling When designing a solution algorithm, look not only at the cohesion of modules but also at the flow of information between modules Coupling is a measure of the extent of information interchange between modules Tight coupling implies large dependence on the structure of one module by another The five levels of coupling are listed in a scale from the poorest module design quality to the best as shown on page 149 of the textbook

Simple Program Design, Fourth Edition Chapter 9 16 Common Coupling Common coupling occurs when modules reference the same global data structure A data structure is a collection of related data items, such as a record or an array Examine the hierarchy chart and pseudocode examples illustrated on page 150 of the textbook

Simple Program Design, Fourth Edition Chapter 9 17 External Coupling External coupling occurs when two or more modules access the same global data variable It is similar to common coupling except that the global data is an elementary data item, rather than a data structure The pseudocode example on page 151 shows two modules that exhibit external coupling because they share the same global data item

Simple Program Design, Fourth Edition Chapter 9 18 Control Coupling Control coupling occurs when a module passes another module a control variable that is intended to control the other module’s logic The weakness of control-coupled modules is that the passing of the control field between modules implies that one module is aware of the internal logic of the other Examine the pseudocode listed on pages 151 and 152 of the textbook

Simple Program Design, Fourth Edition Chapter 9 19 Stamp Coupling Stamp coupling occurs when one module passes a non-global data structure to another module in the form of a parameter Stamp-coupled modules demonstrate loose coupling and offer good module design quality The only relationship between the two modules is the passing of the data structure between them as shown on page 152 in the pseudocode example

Simple Program Design, Fourth Edition Chapter 9 20 Data Coupling Data coupling occurs when a module passes a non-global data variable to another module It is similar to stamp coupling except that the non-global data variable is an elementary data item, not a data structure Examine the hierarchy chart and pseudocode examples of data coupling illustrated on page 153 of the textbook

Simple Program Design, Fourth Edition Chapter 9 21 A Summary of Coupling Levels If the programming language allows it, try to uncouple each module from its surroundings by: 1.Passing data to a subordinate module in the form of parameters, rather than using global data 2.Writing each subordinate module as a self- contained unit that can: accept data passed to it; operate on it without reference to other parts of the program; and pass information back to the calling module, if required

Simple Program Design, Fourth Edition Chapter 9 22 Summary This chapter revised the six steps to be followed when using top-down modular design to develop a solution to a typical programming problem Cohesion and coupling were introduced and must be considered when designing modular programs Cohesion is a measure of the internal strength of a module The higher the cohesion, the better the module Seven levels of cohesion were given and each level was discussed, with a pseudocode example provided