Coupling
Types of Modular Coupling
In order of desirability
- Data Coupling (weakest most desirable)
- Control Coupling
- Global Data Coupling
- Internal Data Coupling (strongest least desirable)
- Content Coupling (Unrated)
Data Coupling Output from one module is the input to another Using parameter lists to pass items between routines Object A passes object X to object B Object X and B are coupled A change to X's interface may require a change to B
|
||
Control Coupling Passing control flags between modules so that one module controls the sequencing of the processing steps in another module A sends a message to B B uses a parameter of the message to decide what to do
Problem: A needs to know the messages it can pass to B. A Solution: Decompose the operation into multiple primitive operations
|
||
Global Data CouplingTwo or more modules share the same global data structures Example A method in one object makes a specific reference to a specific external object |
||
Internal Data CouplingOne module directly modifies local data of another module Example: C++ Friends |
||
Lexical Content CouplingSome or all of the contents of one module are included in the contents of another Example: C/C++ header files Solution: Restrict what goes in header file |
Decoupling a Design
Problem: both Kitchen and Cash Register use Food class...too coupled to very different useages.Solution:
|