25-10-2012, 06:05 PM
Coupling and Cohesion
CouplingCohesion.pdf (Size: 59.81 KB / Downloads: 204)
Definition of Coupling
• The degree of interdependence between two
or more components.
– Reducded coupling Þ Reduced Complexity
• Make components as independent as
possible.
– Eliminate unnecessary relationships
– Ease the tightness of necessary relationships.
The fewer the connection, the less chance
there is for the ripple effect.
– Ideally, changing one component should not
require a change in another.
– Should not have to understand details of one
component in order to change another (c.f.
principle of locality).
Coupling Principles
• Create narrow connections
• Create direct Connections
• Create local connections
• Create obvious connections
• Create flexible connections
Direct vs. Indirect Connections
• A direct connection is one in which the
interface between two components can be
understood without having to refer to other
prices of information.
– A method definition including pre- and
postconditions has a more direct interface than
one that does not.
Local vs. Remote Connections
• Local Connection
– All information required to understand
theconnection is present in the connection
itself.
• Remote Connection
– Coupled through global data.
– May be hundreds of lines removed from a call
point.