Coupling (computer programming): Difference between revisions

Content deleted Content added
Low-Coupling / High-Cohesion pattern: It's not a pattern. Rewording 1st para.
Line 26:
 
== Low-Coupling / High-Cohesion ==
Low-Couplingcoupling / Highhigh-Cohesioncohesion is a general goal to achieve when structuring [[computer program]]s, so that they are easier to understand and maintain.
 
The concepts (Low-Coupling / High-Cohesion) are usually related.: Lowlow coupling implies high cohesion and viceversa,vice becauseversa. ifIn wethe putfield togetherof all relationed methods[[object-oriented (High Cohesion)programming]], the connection between classes tends to get lower (Lowlow Couplingcoupling), if we we group related methods of a class together (high cohesion).
 
=== Low Coupling ===
CouplingIn object-oriented programming, coupling is a measure of how strongly one class is connected to another and is increased between Class A and Class B when:.
 
Coupling is increased between two classes A and B if:
 
*A has an attribute that refers to (is of type) B.
Line 38 ⟶ 40:
*A is a subclass of (or implements) B.
 
The disadvantagesDisadvantages of high coupling includesinclude:
 
*A change in one class forces a ripple of changes in other classes.
Line 52 ⟶ 54:
*Operations do many varied activities, often using varied data.
 
The disadvantagesDisadvantages of weak cohesion are:
 
*Difficult to understand.
*Difficult to maintain, because it is constantly affected by changes.
*Difficult to reuse a class because most applicationapplications won’t need a random set of operations attached to a class.
 
=== Related patterns ===