0% found this document useful (0 votes)
7 views

Assignment 02 Se

Uploaded by

yqpxr7d7r6
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Assignment 02 Se

Uploaded by

yqpxr7d7r6
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

NATIONAL UNIVERSITY OF MODERN

LANGUAGES
ISLAMABAD

ASSIGNMENT 02
Submitted By
Wania Azam
(BSAI-068)

Submission Date: December 3, 2024


Coupling and Cohesion in Software Design
Coupling

Coupling refers to the degree of interdependence between different modules or components in


a software system. It measures how closely connected the modules are and how much they
rely on each other.

 Low Coupling: Desirable because it ensures that changes in one module do not
significantly affect others.
 High Coupling: Undesirable because it makes the system fragile and difficult to
maintain.

Types of Coupling:

1. Content Coupling: One module directly modifies or relies on the internal workings
of another (e.g., accessing private data).
2. Common Coupling: Modules share global data, creating dependencies.
3. Control Coupling: One module controls the behavior of another by passing control
information (e.g., flags).
4. Stamp Coupling: Modules share complex data structures but do not use all the
information.
5. Data Coupling: Modules share only the required data through parameters. This is the
most desirable type.
6. Message Coupling: Modules communicate using messages (like in event-driven
systems), ensuring minimal dependency.

Cohesion

Cohesion refers to the degree to which the elements within a single module work together to
perform a single, well-defined task. Higher cohesion is desirable as it makes modules easier
to understand, test, and maintain.

 High Cohesion: Indicates a module is focused and performs a single responsibility.


 Low Cohesion: Indicates a module is doing too many unrelated tasks, leading to
complexity.

Types of Cohesion:

1. Coincidental Cohesion: Elements are grouped arbitrarily with no relationship.


(Worst type)
2. Logical Cohesion: Elements perform similar tasks but are grouped based on type
(e.g., input-output operations).
3. Temporal Cohesion: Elements are related by their execution timing (e.g.,
initialization tasks).
4. Procedural Cohesion: Elements execute a sequence of tasks related by a procedure.
5. Communicational Cohesion: Elements operate on the same data set or contribute to
the same task.
6. Functional Cohesion: All elements contribute to a single, well-defined function.
(Best type)

Example
 High Cohesion: A module dedicated to calculating tax performs only tax-related
calculations.
 Low Coupling: The tax module interacts with other modules through well-defined
APIs, reducing dependency.
 High Coupling: The tax module directly accesses and modifies data from the user
management module.
 Low Cohesion: A module handles tax calculations, user authentication, and report
generation, making it difficult to manage.

You might also like