I was looking at the Decorator Pattern on Wikipedia this morning when I noticed the sample code had at least two flaws. The code that was there at the time is: // Class to be decorated function Coffee() { this.cost = function() { return 1; }; } // Decorator A function Milk(coffee) { this.cost = function() { return coffee.cost() + 0.5; }; } // Decorator B function Whip(coffee) { this.cost = function()...
Read More