Software Engineering - Independence of Modules

Table of contents

1. Module independence

2. Coupling

3. Cohesion


1. Module independence

Definition: It means that each module in the software system only involves specific sub-functions required by the software, and the interface with other modules in the software system is simple.

Metrics for Module Independence: Inter-Module Coupling and Inter-Module Cohesion

Coupling: is a measure of the tightness of interconnection between modules. (The closer the connection between the modules, the more connections, the higher the coupling, and the weaker the module independence)

Cohesion: It is a measure of the functional strength of a module (the degree to which elements within a module are combined with each other). (The closer the connection between the various elements in a module, the higher its cohesion, relatively, the lower the coupling between it and other modules, and the stronger the module independence)

 A module with strong module independence should be a module with high cohesion and low coupling .

2. Coupling

Coupling is a measure of how modules are related to each other in a program's structure, and it depends on the complexity of the interfaces between modules, how the modules are invoked, and the type of information passing through the interfaces.

(1) Indirect coupling : There is no direct relationship between the two modules, and the connection between them is completely realized through the control and calling of the main module. Indirectly coupled modules are the most independent

(2) Data coupling: When a module accesses another module, it exchanges input and output information with each other through simple data parameters (not control parameters, public data structures or external variables).

(3) Marker coupling: A group of modules transfer record information through parameter tables, which is marker coupling.

(4)   Control coupling: If the parameters passed by one module to another module contain control information, which is used to control the execution logic in the accepting module, the coupling between them is called control coupling.

(5) External coupling: If a group of modules all access the same global simple variable instead of the same global data structure, and the information of the global variable is not passed through the parameter table.

(6) Public coupling : If a group of modules all access the same common data environment, the coupling between them is called public coupling. A common data environment can be a global data structure, a shared communication area, a common coverage area of ​​memory, etc.

(7) Content coupling:

        1) One module directly accesses the internal data of another module.  

        2) One module does not go inside another module through normal entry.  

        3) Some program codes of the two modules overlap. (only possible in assembly language).

        4) A module has multiple entries.

        This coupling is the weakest of module independence.

3. Cohesion

Cohesion is a measure of how tightly the elements of a module are combined with each other.

(1) Coincidentally cohesive : When there is no connection between the various parts in a module, or even if there is a connection, the connection is very loose, then this module is called a coincidentally cohesive module, which is the module with the lowest degree of cohesion .

(2) Logical cohesion: combine several related functions together, and each time it is called, the judgment parameter sent to the module determines which function the module should execute

( 3) Time aggregation : Most time aggregation modules are multi-functional modules, but the execution of each function of the module is related to time, and it is usually required that all functions must be executed within the same time period. Example: Init Module and Terminate Module

(4) Process cohesion : If the processing within a module is related and must be executed in a specific order, it is process cohesion.

(5 ) Communication cohesion : If each functional part in a module uses the same input data or produces the same output data, it is called a communication cohesion module.

(6) Information cohesion: This module completes multiple functions, and each function operates on the same data structure. Each function has a unique entry point. This module will determine which function to execute according to different requirements.

(7) Functional cohesion : each part of a module is an essential part to complete a specific function, or all parts of the module work together to complete a specific function, closely connected and inseparable of. The module is called a functional cohesive module. Functionally cohesive modules have the highest degree of cohesion.

Guess you like

Origin blog.csdn.net/TAO1031/article/details/127756467