AreaCalculator.area(shape) · one method, switches on type
«interface» Shape { area() } · one class per shape
Add a shape to begin
Same feature — computing a shape's area — built two ways. Add the same shape in each mode and watch what it costs you. The Closed design makes you reopen tested code; the Open design lets you just plug in a new class.
closed design
▸Open for extension, closed for modification. One design forces you to edit code that already works; the other adds new behaviour without touching it.