Assignment 02 Se
Assignment 02 Se
LANGUAGES
ISLAMABAD
ASSIGNMENT 02
Submitted By
Wania Azam
(BSAI-068)
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.
Types of Cohesion:
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.