Professional Documents
Culture Documents
1/2009
Indications of Coupling
Coupling Types
Content coupling Common coupling External coupling Control coupling Stamp coupling Data coupling Message coupling Subclass coupling Uncoupled
Content coupling
One component depends on the internal workings of another:
Common Coupling
Coupling via shared data
Global data structures Common blocks
Common Coupling
Coupling via shared data
Global data structures Common blocks
External Coupling
Two components share something externally imposed
Data format Communication protocol Device interface
Control Coupling
Component passes control parameters to coupled components. May be either good or bad, depending on situation.
Stamp Coupling
Component A passes a data structure to component B B only uses part of the data
Data Coupling
Component A passes data to component B Not the same as Stamp Coupling:
Data (a representation), not a data structure (an implementation).
Message Coupling
Components communicate only through a public interface Messages are parameterless (events)
Uncoupled
Completely uncoupled components are not systems. Systems are made of interacting components.
Coupling Types
Content coupling Common coupling External coupling Control coupling Stamp coupling
Cohesion
The degree to which all elements
Coincidental Cohesion
Accidental Worst form
high
Logical Cohesion
Several logically related elements are in the same component. Not related functionally, but related logically.
Temporal Cohesion
Elements of a component are related by timing Elements are grouped by when they are processed
Procedural Cohesion
Elements of a component are related only to ensure a particular order of execution Common for input and output to be unrelated Common to pass partial results Control flows between modules Actions are still weakly connected and unlikely to be reusable
Communicational Cohesion
Elements of a component are related by the data that they process Component performs a series of actions related by a sequence of steps to be followed. All actions are performed on the same data.
Sequential Cohesion
The output of one component is the input to another. Good situation
Informational Cohesion
Module performs a number of actions, each with its own entry point, with independent code for each action, all performed on the same data.
Functional Cohesion
Every essential element to a computation is contained in the component. Every element in the component is essential to the computation. Ideal situation.
Cohesion
Design by contract
Contract: Agreement between two parties Mutual obligations (pre conditions) Benefits (post conditions) Consistency (invariants)
Prototype design