PadhaikoAll subjects

Past exam question: Assignment 3, Q24

Instrumentation · 5 marks

Open in the Padhaiko app

Topic: Software for Instrumentation Application

Question

Explain Coupling & Cohesion in detail.

Solution

Modularity Principle (High Cohesion, Low Coupling): In instrumentation software design, complex firmware or application software is decomposed into independent modules. Good modular design aims for maximum cohesion (all elements inside a module work together toward a single task) and minimum coupling (minimal interdependence between separate modules).

Cohesion (Intra-Module Focus — Ranked Worst to Best): Cohesion measures how closely related the responsibilities and elements within a single module are:

Seven Levels of Cohesion (Worst to Best)
LevelQualityDescription
1. CoincidentalWorstElements are grouped arbitrarily with no meaningful functional relationship.
2. LogicalPoorElements perform logically similar tasks (e.g., all I/O routines) selected by an external control flag.
3. TemporalLowElements are grouped only because they execute at the same time (e.g., an init_all() startup routine).
4. ProceduralModerateElements are grouped because they follow a fixed procedural sequence of execution.
5. CommunicationalGoodElements operate on the same input/output data record or share the same peripheral device.
6. SequentialVery GoodOutput from one element serves directly as input to the next (e.g., read_adc scale filter).
7. FunctionalBest (Highest)Every element in the module contributes exclusively to performing one single, well-defined task.

Coupling (Inter-Module Dependency — Ranked Best to Worst): Coupling measures the degree of interconnection and dependency between different modules:

Six Types of Coupling (Best / Loosest to Worst / Tightest)
TypeQualityDescription
1. Data CouplingBest (Loosest)Modules communicate solely by passing elementary local data values as function arguments.
2. Stamp CouplingGoodModules pass a composite data structure (struct) when the receiver only needs a subset of its fields.
3. Control CouplingModerateOne module passes a control flag or mode code that dictates internal branching in another module.
4. Subclass CouplingModerate (OOP)Dependency between a derived child class and its parent base class in object-oriented inheritance.
5. Common CouplingPoorMultiple modules read and write shared global data areas (e.g., C extern globals), risking side effects.
6. Content CouplingWorst (Tightest)One module directly reads/modifies internal data or branches into the instructions of another module.
Answer:

Cohesion measures how tightly elements within a single module belong to one unified task (ranked worst-to-best: Coincidental, Logical, Temporal, Procedural, Communicational, Sequential, Functional). Coupling measures interdependence between modules (ranked best-to-worst: Data, Stamp, Control, Subclass, Common, Content). Well-engineered instrumentation software maximizes functional cohesion and minimizes coupling toward data coupling.

All past exam questions for Instrumentation