Espresso
EspWithMilk
EspMilkSugar
EspWithSugar
A subclass per combination
1class EspressoWithMilk extends Espresso { ... }2class EspressoWithMilkAndSugar extends Espresso { ... }3// every new add-on doubles the subclasses 💥
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 problemAdd behaviour to an object by WRAPPING it in another object of the same type — stack as many layers as you like, at runtime.
1class EspressoWithMilk extends Espresso { ... }2class EspressoWithMilkAndSugar extends Espresso { ... }3// every new add-on doubles the subclasses 💥
Modelling each add-on combo as a subclass means a class for every mix — milk, sugar, milk+sugar, …