Low Coupling and High Cohesion are basic design principles in both functional programming and object orientation. What is coupling?
Coupling is the measure of the strength of association by a connection from one module to another. At least that is one of the definitions I found when researching the topic. Another one is that
Coupling is the degree of interaction between modules. Following some original research from 1974 by W. P. Stevens, G. J. Myers and L. L. Constantine,
Structured Design, IBM Systems Journal Volume 13, Issue 2, Pages 115-139, there are several types of coupling and different degrees of its strength. The same is true for cohesion. These are a lot of definitions to remember -
flashcards to the rescue.
Flashcards
So I created a deck of cards about coupling and cohesion. It contains 115 questions and covers
- Definition of Coupling
- Coupling based on the type of its dependency.
- Types of coupling by strength.
- Examples of code elements with certain types of coupling.
- Postel's Law
- Coupling Contributing Factors
- Definition of Cohesion
- Cohesion based on the type of the module's elements' relationship.
- Types of cohesion by strength.
- Examples of code elements with certain types of cohesion.
- Problems caused by low strength cohesion.
These are just basic definitions and code samples. Some definitions seem outdated or incomplete but I wanted to follow the original wording from Stevens, Myers and Constantine. So take them in the light of 1974. ;-) Also I am missing newer and more high level aspects of coupling and cohesion, e.g.
Connascence.
Download
I use Anki digital flashcards. Its
apkg
files can be used with
Anki for Windows, Linux, Mac and Android. For iOS there is
AnkiApp but I did not confirm that it works with
apkg
. (Liviu Jianu reports that its desktop version does not work with my decks. Thank you Liviu.) Download the
Coupling_and_Cohesion.apkg here.