SlideShare a Scribd company logo
1 of 40
Coupling and Cohesion 
Pfleeger, S., Software Engineering Theory 
and Practice. Prentice Hall, 2001.
Characteristics of Good Design 
• Component independence 
– High cohesion 
– Low coupling 
• Exception identification and handling 
• Fault prevention and fault tolerance
Coupling: Degree of dependence 
among components 
No dependencies Loosely coupled-some dependencies 
Highly coupled-many dependencies 
High coupling makes modifying 
parts of the system difficult, e.g., 
modifying a component affects all 
the components to which the 
component is connected.
Range of Coupling 
High Coupling 
Loose 
Low 
Content 
Common 
Control 
Stamp 
Data 
Uncoupled
Content coupling 
• Definition: One component references 
contents of another 
• Example: 
– Component directly modifies another’s data 
– Component refers to local data of another 
component in terms of numerical 
displacement 
– Component modifies another’s code, e.g., 
jumps into the middle of a routine
Example of Content Coupling-1 
Part of program handles lookup for customer. 
When customer not found, component adds 
customer by directly modifying the contents of 
the data structure containing customer data.
Example of Content Coupling-2 
Part of program handles lookup for customer. 
When customer not found, component adds 
customer by directly modifying the contents of 
the data structure containing customer data. 
Improvement: 
When customer not found, component calls the 
AddCustomer() method that is responsible for 
maintaining customer data.
Common Coupling 
• Definition: Two components share data 
– Global data structures 
– Common blocks 
• Usually a poor design choice because 
– Lack of clear responsibility for the data 
– Reduces readability 
– Difficult to determine all the components that 
affect a data element (reduces maintainability) 
– Difficult to reuse components 
– Reduces ability to control data accesses
Example-1 
Process control component maintains current data 
about state of operation. Gets data from multiple 
sources. Supplies data to multiple sinks. 
Each source process writes directly to global data 
store. Each sink process reads directly from global 
data store.
Example-2 
Process control component maintains current data 
about state of operation. Gets data from multiple 
sources. Supplies data to multiple sinks. 
Each source process writes directly to global 
data store. Each sink process reads directly 
from global data store. 
Improvement 
Data manager component is responsible for 
data in data store. Processes send data to and 
request data from data manager.
Control Coupling 
• Definition: Component passes control 
parameters to coupled components. 
• May be either good or bad, depending on 
situation. 
– Bad when component must be aware of 
internal structure and logic of another module 
– Good if parameters allow factoring and reuse 
of functionality
Example 
• Acceptable: Module p calls module q and q 
passes back flag that says it cannot complete 
the task, then q is passing data 
• Not Acceptable: Module p calls module q and q 
passes back flag that says it cannot complete 
the task and, as a result, writes a specific 
message.
Stamp Coupling 
• Definition: Component passes a data structure 
to another component that does not have 
access to the entire structure. 
• Requires second component to know how to 
manipulate the data structure (e.g., needs to 
know about implementation) 
• May be necessary due to efficiency factors: this 
is a choice made by insightful designer, not lazy 
programmer.
Example-1 
Customer billing system 
The print routine of the customer billing 
accepts a customer data structure as an 
argument, parses it, and prints the name, 
address, and billing information.
Example-2 
Customer Billing System 
The print routine of the customer billing 
accepts a customer data structure as an 
argument, parses it, and prints the name, 
address, and billing information. 
Improvement 
The print routine takes the customer name, 
address, and billing information as an 
argument.
Data Coupling 
• Definition: Two components are data 
coupled if there are homogeneous data 
items. 
• Every argument is simple argument or 
data structure in which all elements are 
used 
• Good, if it can be achieved. 
• Easy to write contracts for this and modify 
component independently.
Key Idea in Object-Oriented 
Programming 
• Object-oriented designs tend to have low 
coupling.
Cohesion 
• Definition: The degree to which all elements of a 
component are directed towards a single task 
and all elements directed towards that task are 
contained in a single component. 
• Internal glue with which component is 
constructed 
• All elements of component are directed toward 
and essential for performing the same task 
• High is good
Range of Cohesion 
High Cohesion 
Low 
Functional 
Informational 
Sequential 
Communicational 
Procedural 
Temporal 
Logical 
Coincidental
Coincidental Cohesion 
• Definition: Parts of the component are only 
related by their location in source code 
• Elements needed to achieve some 
functionality are scattered throughout the 
system. 
• Accidental 
• Worst form
Example 
• Print next line 
• Reverse string of characters in second 
argument 
• Add 7 to 5th argument 
• Convert 4th argument to float
Logical Cohesion 
• Definition: Elements of component are 
related logically and not functionally. 
• Several logically related elements are in 
the same component and one of the 
elements is selected by the client 
component.
Example-1 
• A component reads inputs from tape, disk, 
and network. All the code for these 
functions are in the same component. 
• Operations are related, but the functions are 
significantly different.
Example-2 
• A component reads inputs from tape, disk, 
and network. All the code for these 
functions are in the same component. 
Operations are related, but the functions 
are significantly different. 
Improvement 
• A device component has a read operation 
that is overridden by sub-class 
components. The tape sub-class reads 
from tape. The disk sub-class reads from 
disk. The network sub-class reads from the 
network.
Temporal Cohesion 
• Definition: Elements of a component are 
related by timing. 
• Difficult to change because you may have 
to look at numerous components when a 
change in a data structure is made. 
• Increases chances of regression fault 
• Component unlikely to be reusable.
Example-1 
• A system initialization routine: this routine 
contains all of the code for initializing all of the 
parts of the system. Lots of different activities 
occur, all at init time.
Example-2 
• A system initialization routine: this routine 
contains all of the code for initializing all of 
the parts of the system. Lots of different 
activities occur, all at init time. 
Improvement 
• A system initialization routine sends an 
initialization message to each component. 
• Each component initializes itself at 
component instantiation time.
Procedural Cohesion 
• Definition: Elements of a component are 
related only to ensure a particular order of 
execution. 
• Actions are still weakly connected and 
unlikely to be reusable
Example 
... 
Read part number from 
data base 
update repair record on 
maintenance file. 
... 
• May be useful to 
abstract the intent of 
this sequence. Make 
the data base and 
repair record 
components handle 
reading and updating. 
Make component that 
handles more 
abstract operation.
Communicational Cohesion 
• Definition: Module performs a series of 
actions related by a sequence of steps to 
be followed by the product and all actions 
are performed on the same data
Example 
• Update record in data 
base and send it to 
the printer. 
• database.Update 
(record). 
• record.Print().
Sequential Cohesion 
• The output of one component is the input 
to another. 
• Occurs naturally in functional programming 
languages 
• Good situation
Informational Cohesion 
• Definition: Module performs a number of 
actions, each with its own entry point, with 
independent code for each action, all 
performed on the same data. 
• Different from logical cohesion 
– Each piece of code has single entry and single exit 
– In logical cohesion, actions of module intertwined 
• ADT and object-oriented paradigm promote
Functional Cohesion 
• Definition: Every essential element to a 
single computation is contained in the 
component. 
• Every element in the component is 
essential to the computation. 
• Ideal situation.
Examples of Cohesion-1 
Function A 
Function 
B 
Function 
D 
Function 
C 
Function 
E 
Coincidental 
Parts unrelated 
Function A 
Function A’ 
Function A’’ 
logic 
Logical 
Similar functions 
Time t0 
Time t0 + X 
Time t0 + 2X 
Temporal 
Related by time 
Function A 
Function B 
Function C 
Procedural 
Related by order of functions
Examples of Cohesion-2 
Output of one is input to another 
Function A part 1 
Function A part 2 
Function A part 3 
Functional 
Function A 
Function B 
Function C 
Communicational 
Access same data 
Function A 
Function B 
Function C 
Sequential 
Sequential with complete, related functions
Problem: Define coupling between pairs of modules. 
p 
q 
r s 
t 
u 
1 
2 
3 4 
5 6 
No. In Out 
1 Aircraft type Status flag 
2 ----- List of aircraft 
parts 
3 Function code ----- 
4 ----- List of aircraft 
parts 
5 Part number Part manufacturer 
6 Part number Part name 
Interface Description 
p, t, u access the same 
database in update 
mode
Coupling between pairs of modules 
q r s t u 
p 
q --- --- 
r --- --- 
s --- 
t
Problem: Classify cohesion for 
each module 
• Compute average daily temperatures at various 
sites 
• Initialize sums and open files 
• Create new temperature record 
• Store temperature record 
• Close files and print average temperatures 
• Read in site, time, and temperature 
• Store record for specific site 
• Edit site, time, or temperature field
In Class 
• P1: What is the effect of cohesion on 
maintenance? 
• P2: What is the effect of coupling on 
maintenance? 
• P3: Produce an example of each type of 
cohesion. Justify your answers. 
• P4: Produce an example of each type of 
coupling. Justify your answers.

More Related Content

What's hot

Object Oriented Testing
Object Oriented TestingObject Oriented Testing
Object Oriented TestingAMITJain879
 
Phased life cycle model
Phased life cycle modelPhased life cycle model
Phased life cycle modelStephennancy
 
Requirement analysis and specification
Requirement analysis and specificationRequirement analysis and specification
Requirement analysis and specificationM.E. at GTU- PG School
 
Software design and Software engineering.pptx
Software design and Software engineering.pptxSoftware design and Software engineering.pptx
Software design and Software engineering.pptxDrTThendralCompSci
 
Domain specific Software Architecture
Domain specific Software Architecture Domain specific Software Architecture
Domain specific Software Architecture DIPEN SAINI
 
Quality of software
Quality of softwareQuality of software
Quality of softwarePalak Pandoh
 
state modeling In UML
state modeling In UMLstate modeling In UML
state modeling In UMLKumar
 
Software design and Software engineering.pptx
Software design and Software engineering.pptxSoftware design and Software engineering.pptx
Software design and Software engineering.pptxDrTThendralCompSci
 
Bse 3105 lecture 4-software re-engineering
Bse 3105  lecture 4-software re-engineeringBse 3105  lecture 4-software re-engineering
Bse 3105 lecture 4-software re-engineeringAlonzee Tash
 
Unified process model
Unified process modelUnified process model
Unified process modelRyndaMaala
 
Software Engineering (Software Configuration Management)
Software Engineering (Software Configuration Management)Software Engineering (Software Configuration Management)
Software Engineering (Software Configuration Management)ShudipPal
 
Software Project Management - Staffing
Software Project Management - StaffingSoftware Project Management - Staffing
Software Project Management - StaffingTanishqRongta1
 

What's hot (20)

Ch09
Ch09Ch09
Ch09
 
Object Oriented Testing
Object Oriented TestingObject Oriented Testing
Object Oriented Testing
 
Phased life cycle model
Phased life cycle modelPhased life cycle model
Phased life cycle model
 
Requirement analysis and specification
Requirement analysis and specificationRequirement analysis and specification
Requirement analysis and specification
 
Software design and Software engineering.pptx
Software design and Software engineering.pptxSoftware design and Software engineering.pptx
Software design and Software engineering.pptx
 
Domain specific Software Architecture
Domain specific Software Architecture Domain specific Software Architecture
Domain specific Software Architecture
 
Quality of software
Quality of softwareQuality of software
Quality of software
 
Component level design
Component   level designComponent   level design
Component level design
 
Staffing level estimation
Staffing level estimation Staffing level estimation
Staffing level estimation
 
state modeling In UML
state modeling In UMLstate modeling In UML
state modeling In UML
 
Design notation
Design notationDesign notation
Design notation
 
Software design and Software engineering.pptx
Software design and Software engineering.pptxSoftware design and Software engineering.pptx
Software design and Software engineering.pptx
 
Bse 3105 lecture 4-software re-engineering
Bse 3105  lecture 4-software re-engineeringBse 3105  lecture 4-software re-engineering
Bse 3105 lecture 4-software re-engineering
 
Software prototyping.pptx
Software prototyping.pptxSoftware prototyping.pptx
Software prototyping.pptx
 
Acid properties
Acid propertiesAcid properties
Acid properties
 
Requirement Engineering.ppt
Requirement Engineering.pptRequirement Engineering.ppt
Requirement Engineering.ppt
 
Unified process model
Unified process modelUnified process model
Unified process model
 
Software Engineering (Software Configuration Management)
Software Engineering (Software Configuration Management)Software Engineering (Software Configuration Management)
Software Engineering (Software Configuration Management)
 
Cohesion and coupling
Cohesion and couplingCohesion and coupling
Cohesion and coupling
 
Software Project Management - Staffing
Software Project Management - StaffingSoftware Project Management - Staffing
Software Project Management - Staffing
 

Similar to Couplingand cohesion student

SE-coupling and cohesion.ppt
SE-coupling and cohesion.pptSE-coupling and cohesion.ppt
SE-coupling and cohesion.pptvishal choudhary
 
12 couplingand cohesion-student
12 couplingand cohesion-student12 couplingand cohesion-student
12 couplingand cohesion-studentrandhirlpu
 
Unit-III(Design).pptx
Unit-III(Design).pptxUnit-III(Design).pptx
Unit-III(Design).pptxFajar Baskoro
 
Design engineering cohesion by dinesh
Design engineering cohesion by dineshDesign engineering cohesion by dinesh
Design engineering cohesion by dineshDinesh Kumar
 
Seii unit7 component-level-design
Seii unit7 component-level-designSeii unit7 component-level-design
Seii unit7 component-level-designAhmad sohail Kakar
 
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)Masayuki Nii
 
Pressman ch-11-component-level-design
Pressman ch-11-component-level-designPressman ch-11-component-level-design
Pressman ch-11-component-level-designOliver Cheng
 
Diksha sda presentation
Diksha sda presentationDiksha sda presentation
Diksha sda presentationdikshagupta111
 
Software Eng S3 ( Software Design ).pptx
Software Eng S3 ( Software Design ).pptxSoftware Eng S3 ( Software Design ).pptx
Software Eng S3 ( Software Design ).pptxgauriVarshney8
 
Module Architecture of React-Redux Applications
Module Architecture of React-Redux ApplicationsModule Architecture of React-Redux Applications
Module Architecture of React-Redux ApplicationsAndrii Sliusar
 
Component based development | what, why and how
Component based development | what, why and howComponent based development | what, why and how
Component based development | what, why and howRakesh Kumar Jha
 
Representational state transfer (rest) architectural style1.1
Representational state transfer (rest) architectural style1.1Representational state transfer (rest) architectural style1.1
Representational state transfer (rest) architectural style1.1Vinod Wilson
 
agri-commerce hub project-documentation report.pptx
agri-commerce hub project-documentation report.pptxagri-commerce hub project-documentation report.pptx
agri-commerce hub project-documentation report.pptxMuhweziAmon4
 
Design concepts and principles
Design concepts and principlesDesign concepts and principles
Design concepts and principlessaurabhshertukde
 
Managing software project, software engineering
Managing software project, software engineeringManaging software project, software engineering
Managing software project, software engineeringRupesh Vaishnav
 
Coupling coheshion tps
Coupling coheshion tpsCoupling coheshion tps
Coupling coheshion tpsPreeti Mishra
 

Similar to Couplingand cohesion student (20)

SE-coupling and cohesion.ppt
SE-coupling and cohesion.pptSE-coupling and cohesion.ppt
SE-coupling and cohesion.ppt
 
12 couplingand cohesion-student
12 couplingand cohesion-student12 couplingand cohesion-student
12 couplingand cohesion-student
 
Unit-III(Design).pptx
Unit-III(Design).pptxUnit-III(Design).pptx
Unit-III(Design).pptx
 
Design engineering cohesion by dinesh
Design engineering cohesion by dineshDesign engineering cohesion by dinesh
Design engineering cohesion by dinesh
 
Seii unit7 component-level-design
Seii unit7 component-level-designSeii unit7 component-level-design
Seii unit7 component-level-design
 
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
 
Chapter Three.pptx
Chapter Three.pptxChapter Three.pptx
Chapter Three.pptx
 
Pressman ch-11-component-level-design
Pressman ch-11-component-level-designPressman ch-11-component-level-design
Pressman ch-11-component-level-design
 
Diksha sda presentation
Diksha sda presentationDiksha sda presentation
Diksha sda presentation
 
Software Eng S3 ( Software Design ).pptx
Software Eng S3 ( Software Design ).pptxSoftware Eng S3 ( Software Design ).pptx
Software Eng S3 ( Software Design ).pptx
 
Ch 11-component-level-design
Ch 11-component-level-designCh 11-component-level-design
Ch 11-component-level-design
 
Lect17
Lect17Lect17
Lect17
 
Module Architecture of React-Redux Applications
Module Architecture of React-Redux ApplicationsModule Architecture of React-Redux Applications
Module Architecture of React-Redux Applications
 
Component based development | what, why and how
Component based development | what, why and howComponent based development | what, why and how
Component based development | what, why and how
 
Representational state transfer (rest) architectural style1.1
Representational state transfer (rest) architectural style1.1Representational state transfer (rest) architectural style1.1
Representational state transfer (rest) architectural style1.1
 
agri-commerce hub project-documentation report.pptx
agri-commerce hub project-documentation report.pptxagri-commerce hub project-documentation report.pptx
agri-commerce hub project-documentation report.pptx
 
Design concepts and principles
Design concepts and principlesDesign concepts and principles
Design concepts and principles
 
Software design i (2) (1)
Software design   i (2) (1)Software design   i (2) (1)
Software design i (2) (1)
 
Managing software project, software engineering
Managing software project, software engineeringManaging software project, software engineering
Managing software project, software engineering
 
Coupling coheshion tps
Coupling coheshion tpsCoupling coheshion tps
Coupling coheshion tps
 

Recently uploaded

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 

Recently uploaded (20)

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 

Couplingand cohesion student

  • 1. Coupling and Cohesion Pfleeger, S., Software Engineering Theory and Practice. Prentice Hall, 2001.
  • 2. Characteristics of Good Design • Component independence – High cohesion – Low coupling • Exception identification and handling • Fault prevention and fault tolerance
  • 3. Coupling: Degree of dependence among components No dependencies Loosely coupled-some dependencies Highly coupled-many dependencies High coupling makes modifying parts of the system difficult, e.g., modifying a component affects all the components to which the component is connected.
  • 4. Range of Coupling High Coupling Loose Low Content Common Control Stamp Data Uncoupled
  • 5. Content coupling • Definition: One component references contents of another • Example: – Component directly modifies another’s data – Component refers to local data of another component in terms of numerical displacement – Component modifies another’s code, e.g., jumps into the middle of a routine
  • 6. Example of Content Coupling-1 Part of program handles lookup for customer. When customer not found, component adds customer by directly modifying the contents of the data structure containing customer data.
  • 7. Example of Content Coupling-2 Part of program handles lookup for customer. When customer not found, component adds customer by directly modifying the contents of the data structure containing customer data. Improvement: When customer not found, component calls the AddCustomer() method that is responsible for maintaining customer data.
  • 8. Common Coupling • Definition: Two components share data – Global data structures – Common blocks • Usually a poor design choice because – Lack of clear responsibility for the data – Reduces readability – Difficult to determine all the components that affect a data element (reduces maintainability) – Difficult to reuse components – Reduces ability to control data accesses
  • 9. Example-1 Process control component maintains current data about state of operation. Gets data from multiple sources. Supplies data to multiple sinks. Each source process writes directly to global data store. Each sink process reads directly from global data store.
  • 10. Example-2 Process control component maintains current data about state of operation. Gets data from multiple sources. Supplies data to multiple sinks. Each source process writes directly to global data store. Each sink process reads directly from global data store. Improvement Data manager component is responsible for data in data store. Processes send data to and request data from data manager.
  • 11. Control Coupling • Definition: Component passes control parameters to coupled components. • May be either good or bad, depending on situation. – Bad when component must be aware of internal structure and logic of another module – Good if parameters allow factoring and reuse of functionality
  • 12. Example • Acceptable: Module p calls module q and q passes back flag that says it cannot complete the task, then q is passing data • Not Acceptable: Module p calls module q and q passes back flag that says it cannot complete the task and, as a result, writes a specific message.
  • 13. Stamp Coupling • Definition: Component passes a data structure to another component that does not have access to the entire structure. • Requires second component to know how to manipulate the data structure (e.g., needs to know about implementation) • May be necessary due to efficiency factors: this is a choice made by insightful designer, not lazy programmer.
  • 14. Example-1 Customer billing system The print routine of the customer billing accepts a customer data structure as an argument, parses it, and prints the name, address, and billing information.
  • 15. Example-2 Customer Billing System The print routine of the customer billing accepts a customer data structure as an argument, parses it, and prints the name, address, and billing information. Improvement The print routine takes the customer name, address, and billing information as an argument.
  • 16. Data Coupling • Definition: Two components are data coupled if there are homogeneous data items. • Every argument is simple argument or data structure in which all elements are used • Good, if it can be achieved. • Easy to write contracts for this and modify component independently.
  • 17. Key Idea in Object-Oriented Programming • Object-oriented designs tend to have low coupling.
  • 18. Cohesion • Definition: The degree to which all elements of a component are directed towards a single task and all elements directed towards that task are contained in a single component. • Internal glue with which component is constructed • All elements of component are directed toward and essential for performing the same task • High is good
  • 19. Range of Cohesion High Cohesion Low Functional Informational Sequential Communicational Procedural Temporal Logical Coincidental
  • 20. Coincidental Cohesion • Definition: Parts of the component are only related by their location in source code • Elements needed to achieve some functionality are scattered throughout the system. • Accidental • Worst form
  • 21. Example • Print next line • Reverse string of characters in second argument • Add 7 to 5th argument • Convert 4th argument to float
  • 22. Logical Cohesion • Definition: Elements of component are related logically and not functionally. • Several logically related elements are in the same component and one of the elements is selected by the client component.
  • 23. Example-1 • A component reads inputs from tape, disk, and network. All the code for these functions are in the same component. • Operations are related, but the functions are significantly different.
  • 24. Example-2 • A component reads inputs from tape, disk, and network. All the code for these functions are in the same component. Operations are related, but the functions are significantly different. Improvement • A device component has a read operation that is overridden by sub-class components. The tape sub-class reads from tape. The disk sub-class reads from disk. The network sub-class reads from the network.
  • 25. Temporal Cohesion • Definition: Elements of a component are related by timing. • Difficult to change because you may have to look at numerous components when a change in a data structure is made. • Increases chances of regression fault • Component unlikely to be reusable.
  • 26. Example-1 • A system initialization routine: this routine contains all of the code for initializing all of the parts of the system. Lots of different activities occur, all at init time.
  • 27. Example-2 • A system initialization routine: this routine contains all of the code for initializing all of the parts of the system. Lots of different activities occur, all at init time. Improvement • A system initialization routine sends an initialization message to each component. • Each component initializes itself at component instantiation time.
  • 28. Procedural Cohesion • Definition: Elements of a component are related only to ensure a particular order of execution. • Actions are still weakly connected and unlikely to be reusable
  • 29. Example ... Read part number from data base update repair record on maintenance file. ... • May be useful to abstract the intent of this sequence. Make the data base and repair record components handle reading and updating. Make component that handles more abstract operation.
  • 30. Communicational Cohesion • Definition: Module performs a series of actions related by a sequence of steps to be followed by the product and all actions are performed on the same data
  • 31. Example • Update record in data base and send it to the printer. • database.Update (record). • record.Print().
  • 32. Sequential Cohesion • The output of one component is the input to another. • Occurs naturally in functional programming languages • Good situation
  • 33. Informational Cohesion • Definition: Module performs a number of actions, each with its own entry point, with independent code for each action, all performed on the same data. • Different from logical cohesion – Each piece of code has single entry and single exit – In logical cohesion, actions of module intertwined • ADT and object-oriented paradigm promote
  • 34. Functional Cohesion • Definition: Every essential element to a single computation is contained in the component. • Every element in the component is essential to the computation. • Ideal situation.
  • 35. Examples of Cohesion-1 Function A Function B Function D Function C Function E Coincidental Parts unrelated Function A Function A’ Function A’’ logic Logical Similar functions Time t0 Time t0 + X Time t0 + 2X Temporal Related by time Function A Function B Function C Procedural Related by order of functions
  • 36. Examples of Cohesion-2 Output of one is input to another Function A part 1 Function A part 2 Function A part 3 Functional Function A Function B Function C Communicational Access same data Function A Function B Function C Sequential Sequential with complete, related functions
  • 37. Problem: Define coupling between pairs of modules. p q r s t u 1 2 3 4 5 6 No. In Out 1 Aircraft type Status flag 2 ----- List of aircraft parts 3 Function code ----- 4 ----- List of aircraft parts 5 Part number Part manufacturer 6 Part number Part name Interface Description p, t, u access the same database in update mode
  • 38. Coupling between pairs of modules q r s t u p q --- --- r --- --- s --- t
  • 39. Problem: Classify cohesion for each module • Compute average daily temperatures at various sites • Initialize sums and open files • Create new temperature record • Store temperature record • Close files and print average temperatures • Read in site, time, and temperature • Store record for specific site • Edit site, time, or temperature field
  • 40. In Class • P1: What is the effect of cohesion on maintenance? • P2: What is the effect of coupling on maintenance? • P3: Produce an example of each type of cohesion. Justify your answers. • P4: Produce an example of each type of coupling. Justify your answers.

Editor's Notes

  1. Pp220+ pfleeger
  2. Pp220+ pfleeger
  3. Example of good: Sort that takes a comparison function as an argument. The sort function is clearly defined: return a list in sorted order, where sorted is determined by a parameter.
  4. In right hand side, the sort code is unchanged.
  5. Be sure you know the difference between the insightful designer and the lazy programmer. Know what tradeoffs you are making in your design.
  6. I don’t even want to think about it.
  7. I don’t even want to think about it.
  8. I don’t even want to think about it.
  9. I don’t even want to think about it.
  10. I don’t even want to think about it.
  11. I don’t even want to think about it.
  12. I don’t even want to think about it.