Tutorial by Examples

The Observer pattern is used for event handling and delegation. A subject maintains a collection of observers. The subject then notifies these observers whenever an event occurs. If you've ever used addEventListener then you've utilized the Observer pattern. function Subject() { this.observers...
Think of the mediator pattern as the flight control tower that controls planes in the air: it directs this plane to land now, the second to wait, and the third to take off, etc. However no plane is ever allowed to talk to its peers. This is how mediator works, it works as a communication hub among ...
The command pattern encapsulates parameters to a method, current object state, and which method to call. It is useful to compartmentalize everything needed to call a method at a later time. It can be used to issue a "command" and decide later which piece of code to use to execute the comma...
An iterator pattern provides a simple method for selecting, sequentially, the next item in a collection. Fixed Collection class BeverageForPizza { constructor(preferenceRank) { this.beverageList = beverageList; this.pointer = 0; } next() { return this.be...

Page 1 of 1