Shape
RedCircle
BlueCircle
RedSquare
N×M explosion
1class Shape { ... }2class RedCircle extends Shape { ... }3class BlueCircle extends Shape { ... }4class RedSquare extends Shape { ... } // … and on, and on5// 3 shapes × 4 colours = 12 classes 💥
Your free access ends in 7 days — and you haven’t tried it yet. Watch one algorithm run, start to finish. It takes about two minutes.
Try one problemSplit one thing that varies in TWO dimensions into two separate hierarchies, joined by a reference — so each can grow independently instead of multiplying.
1class Shape { ... }2class RedCircle extends Shape { ... }3class BlueCircle extends Shape { ... }4class RedSquare extends Shape { ... } // … and on, and on5// 3 shapes × 4 colours = 12 classes 💥
Subclass every shape × colour combination: RedCircle, BlueCircle, RedSquare… each pairing needs its very own class.