CSE Roadmap

Core tier · about 3 hours · 7 parts

Part 5 of 7 · 1 min read

Its parents

SRP then dependency direction.

CA gives a thought experiment. A web page shows a financial summary. Then the business asks for the same figures as a printed black-and-white report. How much old code must change? A good design changes almost none.

CA gets there in two moves. First, split the work by reason to change (SRP, module 1): one part calculates the figures and another part presents them. Second, point the dependencies the right way: the presenters depend on the calculation, never the reverse. Then a new printed report is only a new presenter. The calculation code does not know it exists.

So OCP is a result, not a separate trick. If classes are split by actor and the high-level code depends on interfaces (module 5 of this level), extension by adding comes almost free.

Check yourself: 1. Which two moves does CA use to reach OCP in the report example? 2. In the report example, which part must not know about the printed report?