New features without editing old codeadvanced
When each variation is its own class behind a shared base, a new one arrives as a new file and nothing that already works is opened — the switch you deleted was the thing every feature used to edit.
Add a thirteen-month calendar to the model without editing a single existing class. The Ethiopian calendar has twelve months of 30 days, then Pagume with 5 days — 6 in a leap year, which comes when year % 4 == 3.
One new class overriding all four hooks, the existing classes untouched, the calendar passed in, and both dates traced.
Published in full, before you start — every point is one of these and there is nothing else.
When each variation is its own class behind a shared base, a new one arrives as a new file and nothing that already works is opened — the switch you deleted was the thing every feature used to edit.
A virtual method is chosen by the object at run time through a table each object points to; a non-virtual one — including one declared new — is fixed by the variable’s type when the code compiles.
Anywhere the parent works the child must work too — and a subclass that compiles perfectly can still break the first caller who relied on something the parent quietly promised.