Design patterns in JavaScript
Abstract bulletproof solutions have been known for long and are usually referred to as Design Patterns. The original 23 Design Patterns in programming were first collected in Design Patterns: Elements of Reusable Object-Oriented Software, an influential book published in 1995 by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (GoF). These patterns are language-agnostic. Nonetheless, Addy Osmani in his online book Learning JavaScript Design Patterns (http://addyosmani.com/resources/essentialjsdesignpatterns/book/) shows how some of the GoF's patterns can be implemented particularly in JavaScript.
Here we won't repeat his work; instead we'll examine how we can combine the patterns. One of the common problems in JavaScript development is communication between dynamically created objects. For instance, we have an object and need to call a method (baz
) of object bar
from foo
. However, we cannot know if bar
is already available. GoF&apos...