Search

Monday, March 9, 2015
0 comments

Coupling in borland C language

10:19 PMMonday, March 9, 2015
Coupling measures the strength of all relationships between functional units. It is the measure of the interdependence of one module to that of another. The program should have low coupling. Low coupling minimize the cause of errors in other modules. The errors in the other modules are caused because of the change in one module.

Definition: Coupling can be defined as the degree of interdependence between two or more modules. The reduction in coupling reduces the complexity of the program. While designing a program, make each module as independent as possible eliminating unnecessary relationships.

The following figure shows the types of coupling that exists in programming:
Types of Coupling:
1. No direct coupling
2. Normal coupling
    2.1   Data coupling
    2.2   Stamp coupling
    2.3   Control coupling
3. Common coupling
4. Content coupling

No direct coupling: These are the independent modules of the program. They are not really components of a single program.

Normal coupling: Two modules, X and Y, are normally coupled if X calls Y, Y returns to X and all information passed between them is by parameters in the call.

Data coupling: Two modules are said to be data coupled if they communicate by passing parameters. This is the most common type of coupling. Try to keep the parameters as minimum as possible.

Stamp coupling: Two modules are said to be stamp coupled if they communicate through a passed data structure that contains more information than necessary for them to perform their operations. A complete piece of data is passed between the modules.

Control coupling: Two modules are said to be control coupled if they communicate with the help of at least one "control flag". The control flag controls internal logic of the module.

Common coupling: Two modules are said to be common coupled if both of them share the same global data area. This type of coupling is really undesirable. Problem or error in one module can affect the other modules. Even it is difficult to identify the affected modules.

Content coupled: Two modules are content coupled if one module changes a statement in another, one module references or alters data contained inside another module or one module branches into another module.

The cohesion exists is within the modules where as the coupling exists between modules within the program. The law of program development is:

"Minimize the COUPLING and Maximize the COHESION"
Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top