0% found this document useful (0 votes)
139 views4 pages

Types of Coupling and Cohesion

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views4 pages

Types of Coupling and Cohesion

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Describe different types of coupling and cohesion. How is design evaluation performed?

In software engineering, coupling and cohesion are key concepts that relate to the design of
systems. Understanding these concepts can help in evaluating and improving software design.

What is Coupling and Cohesion?

Conceptual design of the system:


 Written in simple language i.e. customer understandable language.
 Detailed explanation about system characteristics.
 Describes the functionality of the system.
 It is independent of implementation.
 Linked with requirement document.
Technical Design of the System:
 Hardware component and design.
 Functionality and hierarchy of software components.
 Software architecture
 Network architecture
 Data structure and flow of data.
 I/O component of the system.
 Shows interface.
Coupling

Types of Coupling

Coupling refers to the degree of interdependence between software modules. It indicates how
closely connected different components are. Lower coupling is generally preferred because it
leads to more modular and maintainable code. Here are the main types of coupling:

1. Content Coupling: One module accesses the internal data of another module. This is the
highest degree of coupling and is usually avoided.
2. Common Coupling: Multiple modules share a common global variable. Changes to this
variable can affect all modules, making maintenance difficult.
3. External Coupling: Modules depend on externally defined data formats or protocols.
This can create issues if the external definitions change.
4. Control Coupling: One module controls the behavior of another by passing it
information on what to do. This can lead to tightly coupled code.
5. Stamp Coupling: Modules share a composite data structure, but only some of the data is
used by each module. This can lead to unnecessary dependencies.
6. Data Coupling: Modules share data through parameters. This is the lowest level of
coupling and is generally considered acceptable.
Cohesion

Cohesion refers to how closely related and focused the responsibilities of a single module are.
Higher cohesion within a module means that its functions are closely related, making the module
easier to maintain and understand. The types of cohesion, from lowest to highest, are:

1. Coincidental Cohesion: The components are grouped arbitrarily; there’s no significant


relationship between them.
2. Logical Cohesion: Components are related logically but perform different tasks. For
instance, a module that handles multiple types of input.
3. Temporal Cohesion: Components are grouped by when they are executed. For example,
initialization routines that are run at startup.
4. Procedural Cohesion: Components are grouped because they always follow a certain
sequence of execution.
5. Communicational Cohesion: Components are related by the fact that they operate on the
same data set.
6. Sequential Cohesion: The output from one component is the input to another. This forms
a clear sequence of operations.
7. Functional Cohesion: All components of a module contribute to a single, well-defined
task. This is the highest and most desirable level of cohesion.

Design Evaluation

Evaluating design in software engineering typically involves assessing the coupling and cohesion
of modules. Here are some common methods for evaluation:

1. Code Review: Peers review code to identify areas of high coupling and low cohesion,
suggesting refactoring where necessary.
2. Static Analysis Tools: Tools can analyze code for metrics related to coupling and
cohesion, providing quantitative data.
3. Design Patterns: Using established design patterns can promote low coupling and high
cohesion by providing proven architectural solutions.
4. Refactoring: Regular refactoring sessions help improve code structure by reducing
coupling and increasing cohesion.
5. Unit Testing: Well-structured, cohesive modules are easier to unit test. If testing reveals
difficulties, it may indicate a need for better design.
6. Metrics Analysis: Employing metrics such as LCOM (Lack of Cohesion of Methods) for
cohesion and coupling metrics can help quantify design quality.

Difference Between Coupling and Cohesion


Aspect Coupling Cohesion
Definition Degree of interdependence between Degree of relatedness and focus within a
modules or components within a system. module or component.
Focus Interaction between modules. Composition of elements within a
module.
Impact on Changes in one module can impact Changes within a module are contained.
Change others.
Flexibility High coupling reduces system flexibility, High cohesion enhances system
as changes are likely to propagate. flexibility, as changes are localized.
Maintenance High coupling increases maintenance High cohesion simplifies maintenance, as
complexity, as changes are widespread. changes are confined.
Testing Coupled modules are harder to test in Cohesive modules are easier to test, as
isolation. functionality is well-contained.
Reuse Coupled modules are less reusable due to Cohesive modules are more reusable due
dependencies. to clear and focused functionality.
Dependency Coupling represents module dependency. Cohesion represents module unity and
purpose.
Design Goal Aim for low coupling to minimize Aim for high cohesion to ensure focused
interdependencies. and understandable modules.
Types Content, Common, External, Control, Functional, Sequential,
Stamp, Data, No Coupling. Communicational, Procedural, Temporal,
Coincidental.
Objective Reduce interaction and dependencies for Group-related elements to achieve a well-
system stability. defined purpose.
System Impact High coupling can lead to cascading High cohesion promotes maintainability
failures and rigid architectures. and adaptable architectures.

You might also like