Lecture # 9 (SDA)
Lecture # 9 (SDA)
Lecture - 9
• This evaluation of their cohesion assumes that the routines do what their
names say they do—if they do anything else, they are less cohesive and
poorly named
• Several other kinds of cohesion are normally considered to be less than ideal
Sequential cohesion
• It exists when a routine contains operations that must be performed
in a specific order (The output from one part is the input to another
part)
• Module B has a function process_data that takes some data and calls
the function from Module A.
• The coupling here is based on the data (the value) that is being
passed between the modules. However, this is an example of data
coupling because Module B doesn't need to know how
calculate_square is implemented in Module A, as long as it receives
the required data.
• So, Data coupling is a form of coupling that encourages
modular and maintainable software design by promoting
independence between modules while allowing them to
communicate through well-defined data interfaces.
Stamp coupling
• Two modules are stamp coupled, if they communicate using a data
item such as a record in PASCAL or a structure in C.
• Module B sets the value of task_type and calls the function in Module
A.
• Modules A and B are common coupled because they share the global
variable shared_variable. If changes are made to the way the variable
is used or if additional modules are introduced that interact with this
global variable, it can lead to unintended side effects and make the
system more challenging to maintain.
• To reduce common coupling, software design principles such
as encapsulation and information hiding are often employed.
Instead of sharing global variables, modules should
communicate through well-defined interfaces and use
parameters or return values to exchange data. This promotes
a more modular, maintainable, and scalable software
architecture.
Content coupling
• Content coupling exists between two modules, if they share code, e.g. a
branch from one module into another module.