Example 1 — Split a weather station into modules
Show the steps and the answer
Group the jobs by purpose: Sensor (read the temperature), Storage (keep today's readings), Calculations (°C to °F, high and low), Display (show results).
Each module gets one kind of work, which is high cohesion: the arithmetic is together and the screen code is together.
Give each a small interface: Sensor.read() returns °C; Storage.add(c) and Storage.today(); Calc.toF(c) returns c × 9/5 + 32, plus Calc.high(list) and Calc.low(list); Display.show(text).
Other modules use only these names, so how each module works inside stays its own business.
Trace one minute: Sensor.read() gives 20; Storage.add(20); Calc.toF(20) = 20 × 9/5 + 32 = 68; Display.show('20 °C / 68 °F').
Following one reading through the interfaces checks that each module gets what it needs and nothing more.
New sensor: rewrite only the inside of Sensor.read(), keeping it returning °C.
No other module knows how the sensor works, so the change stays inside one module. That is low coupling paying off.
Answer: Four modules: Sensor (read), Storage (add, today), Calculations (toF, high, low) and Display (show). A new sensor changes only the inside of Sensor.
Takeaway: Group code by job and connect the groups through a few named inputs and outputs, so that a change to one part stays in that part.