Vous êtes sur la page 1sur 1

Cohesion & Coupling (Modularity)

The concept of modularity explains the level of decomposition. It is most feasible to have a system with
low coupling and high cohesion.
High coupling makes modifying parts of the system difficult;
Ex: Modifying a component affect all the components to which the component is connected.
1. Cohesion
Cohesion refers to the level of strength and unity with which different components of a software program
i.
Functional Cohesion: Components are included into a single function, which performs particular
tasks.
ii.
Layer cohesion: The module content is available in different layers. Therefore the higher layer
will access the features of the lower layer.
In other words, System is divided into layers.
Ex: Specialization
iii. Communicational cohesion: When considering a class, all operations or methods within the
class will be accessing the same member data.
iv.
Sequential cohesion: Inside one main operation there can be several minor operations, where the
operations are executed in a sequence.
v.
Procedural cohesion: Certain components can be group together as a procedure. (can be
unrelated activities, in which control passes from one activity to the next)
Ex: Subroutines in some programming languages can be taken as an example.
vi.
Temporal cohesion - time based: Operations which are performed with respect to time is
considered as a temporal cohesion.
2. Coupling
Coupling refers to the degree to which software components are dependent upon each other
i.
Content coupling: Two integrated modules will perform a content coupling when the
modification of one module will affect the content of another.
ii.
Common coupling: When several modules access the same global variable, it is considered as a
common coupling.
iii. Control coupling: When components pass controlled information mainly using Boolean data
types, a control coupling will be activated.
iv.
Stamp coupling: When a particular function is passing a data structure it is called as stamp
coupling.
Stamp could be an array, linked list, stack, queue etc.
v.
Data coupling: Two functions communicate by passing data as parameters using a simple
argument.
Eg: int, char, float
vi.
Routine- call coupling: When a subroutine or a function is being called there may be an
activation of another component.
vii.
Type use coupling: Attributes which are defined in a super class is used by the sub classes.
viii. External Coupling: Modules further communicate with external devices such as printers.
When a module has a dependency on such things as OS, shared libraries or hardware, it is best to
reduce the number of places in where such dependencies exist.

Vous aimerez peut-être aussi