The “prototype” Property
Pseudo Class Inheritance
Inheritance: Practice Hints
Avoid a too long prototype chain
Avoid extending prototypes of built-in objects
Use framework functions for extending objects:
Page Code Behind as Module
(HTML + CSS)
Advantages vs. Disadvantages
Simple in development
Possibility of using a page base class
Becomes too large in case of a complex page
Hard in automated testing
Can’t be used with SPA
Façade Pattern Intent
Provide a unified interface to a set of interfaces in a
subsystem. Facade defines a higher-level interface that
makes the subsystem easier to use.
A Complex System
Façade in jQuery
Façade: Important Consideration
V.3. Behavioral Patterns
“… are concerned with algorithms and the
assignment of responsibilities among objects”
Observer Pattern Intent
Define a one-to-many dependency between objects so that
when one object changes state, all its dependents are
notified and updated automatically.
Mediator Pattern Intent
Define an object that encapsulates how a set of objects
interact. Mediator promotes loose coupling by keeping
objects from referring to each other explicitly, and it lets you
vary their interaction independently.
Mediator as Event Buss
Module 1 Module 2
Publishes an event Listens an event
Transfers an event from the publisher to the listeners
Mediator as Web Modules Manager
Web Module 1 Web Module 2
Web Modules Manager
Manages a web module
Web Module Context
Everything a web
module knows about the
Don’t know about
part of GUI
Strategy Pattern Intent
Define a family of algorithms, encapsulate each one,
and make them interchangeable.
What is a key to success?
Dependency Inversion Principle
A. High level modules should not depend upon
low level modules. Both should depend upon
B. Abstractions should not depend upon details.
Details should depend upon abstractions.
(Robert C. Martin)
The Dependency Inversion Principle (by Robert C. Martin)