SlideShare a Scribd company logo
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Chp4- JavaScript Design Patterns
Design Patterns
1
MedTech – Mediterranean Institute of Technology
CS-Web and Mobile Development
MedTech
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
What is a Pattern?
• A pattern is a reusable solution that can be applied to commonly occurring problems in
software design
• In our case, in writing JavaScript web applications.
• Sorts of templates for how we solve problems - ones which can be used in quite a few
different situations.
• Three main benefits
• Patterns are proven solutions: They provide solid approaches to solving issues in software
development using proven techniques that reflect the experience and insights the developers
that helped define them bring to the pattern.
• Patterns can be easily reused: A pattern usually reflects an out of the box solution that can be
adapted to suit our own needs. This feature makes them quite robust.
• Patterns can be expressive: When we look at a pattern there’s generally a set structure
and vocabulary to the solution presented that can help express rather large solutions quite
elegantly.
2
JavaScript Design Patterns
MedTech
JavaScript Design Patterns
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Summary of Design Patterns
3
Class
Factory Method This makes an instance of several derived classes based on
interfaced data or events.
Object
Abstract Factory Creates an instance of several families of classes without
detailing concrete classes.
Builder Separates object construction from its representation, always
creates the same type of object.
Prototype A fully initialized instance used for copying or cloning.
Singleton A class with only a single instance with global access points.
Creational: Based on the concept of creating an object
MedTech
JavaScript Design Patterns
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Summary of Design Patterns
4
Class
Adapter Match interfaces of different classes therefore classes can work together despite
incompatible interfaces. (uses inheritance)
Object
Adapter Match interfaces of different classes therefore classes can work together despite
incompatible interfaces. (uses composition)
Bridge Separates an object's interface from its implementation so the two can vary independently.
Composite A structure of simple and composite objects which makes the total object more than just
the sum of its parts.
Decorator Dynamically add alternate processing to objects.
Façade A single class that hides the complexity of an entire subsystem.
Flyweight A fine-grained instance used for efficient sharing of information that is contained
elsewhere.
Proxy A place holder object representing the true object.
Structural: Based on the idea of building blocks of objects.
MedTech
JavaScript Design Patterns
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Summary of Design Patterns
5
Class
Interpreter A way to include language elements in an application to match the grammar of the intended language.
Template Method Creates the shell of an algorithm in a method, then defer the exact steps to a subclass.
Object
Chain of Responsibility A way of passing a request between a chain of objects to find the object that can handle the request.
Command Encapsulate a command request as an object to enable, logging and/or queuing of requests, and provides error-
handling for unhandled requests.
Iterator Sequentially access the elements of a collection without knowing the inner workings of the collection.
Mediator Defines simplified communication between classes to prevent a group of classes from referring explicitly to each
other.
Memento Capture an object's internal state to be able to restore it later.
Observer A way of notifying change to a number of classes to ensure consistency between the classes.
State Alter an object's behavior when its state changes.
Strategy Encapsulates an algorithm inside a class separating the selection from the implementation.
Visitor Adds a new operation to a class without changing the class.
Behavioral: Based on the way objects play and work together
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
JS PATTERNS
6
JavaScript Design Patterns
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Creational Pattern
• Deals with the creation of new objects
• Basically three ways to create objects:
• var newObject = {};
• var newObject = Object.create(null);
• var newObject = new Object();
• And four ways to assign a value to an object
1. Dot Syntax
• newObject.someKey = 'Hello World'; // Write properties
• var key = newObject.someKey; // Access properties
2. Square Brackets Syntax
• newObject['someKey'] = 'Hello World';// Write properties
• var key = newObject['someKey']; // Access properties
7
JavaScript Design Patterns
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Creational Pattern
3. defineProperty
Object.defineProperty(newObject, "someKey", {
value: "for more control of the property's behavior",
writable: true,
enumerable: true,
configurable: true
});
5. defineProperties
Object.defineProperties(newObject, {
"someKey": {
value: "Hello World",
writable: true
},
"anotherKey": {
value: "Foo bar",
writable: false
}
});
8
JavaScript Design Patterns
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Constructor Pattern
• Basic Constructors
9
JavaScript Design Patterns
function Car(model, year, miles) {
this.model = model;
this.year = year;
this.miles = miles;
this.toString = function () {
return this.model + " has done " +
this.miles + " miles";
};
}
var civic = new Car("Honda Civic", 2009, 20000);
var mondeo = new Car("Ford Mondeo", 2010, 5000);
console.log(civic.toString());
console.log(mondeo.toString());
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Constructor Pattern
• Constructors with Prototype
10
JavaScript Design Patterns
function Car(model, year, miles) {
this.model = model;
this.year = year;
this.miles = miles;
}
Car.prototype.toString = function () {
return this.model + " has done " +
this.miles + " miles";
};
var civic = new Car("Honda Civic", 2009, 20000);
var mondeo = new Car("Ford Mondeo", 2010, 5000);
console.log(civic.toString());
console.log(mondeo.toString());
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Module Pattern
• Module
• Interchangeable single-part of a larger system that can be easily reused
• Using the notion of IIFE: Immediately Invoked Function Expressions
(function() {
// code to be immediately invoked
}());
• Problem: there is no real privacy in JavaScript
• The typical module pattern is where immediately invoked function expressions
(IIFEs) use execution context to create ‘privacy’
• Here, objects are returned instead of functions.
• In the pattern
• Variables declared are only available inside the module.
• Variables defined within the returning object are available to everyone
11
JavaScript Design Patterns
MedTech
JavaScript Design Patterns
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Module Pattern
12
var basketModule = (function() {
var basket = []; //private
return { //exposed to public
addItem: function(values) {
basket.push(values);
},
getItemCount: function() {
return basket.length;
},
getTotal: function(){
var q = this.getItemCount(), p=0;
while(q--){
p+= basket[q].price;
}
return p;
}
}
}());
MedTech
JavaScript Design Patterns
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Module Pattern
13
//basketModule is an object with properties which can
also be methods
basketModule.addItem({item:'bread',price:0.5});
basketModule.addItem({item:'butter',price:0.3});
console.log(basketModule.getItemCount());
console.log(basketModule.getTotal());
//however, the following will not work:
// (undefined as not inside the returned object)
console.log(basketModule.basket); //error!
//(only possible within the module scope)
console.log(basket); //error
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Façade Pattern
• Structural Pattern
• Convenient, high-level interfaces to larger bodies of code that hide
underlying complexity
• Aims to simplify the presented API to other developers
• The facade pattern :
• Simplifies the interface of a class
• Decouples the class from the code that uses it
• Facades can be used with the Module pattern in order to hide its
methods
• It differs from the Module pattern as the limited public API differs greatly from
the reality of the implementation.
14
JavaScript Design Patterns
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Façade Pattern
15
JavaScript Design Patterns
var module = (function() {
var _private = {
i:5,
get : function() {
console.log('current value:' + this.i);
},
set : function( val ) {
this.i = val;
},
run : function() {
console.log('running');
},
jump: function(){
console.log('jumping');
}
};
return {
facade : function( args ) {
_private.set(args.val);
_private.get();
if ( args.run ) {
_private.run();
}
}
}
}());
module.facade({run: true, val:10});
//outputs current value: 10, running
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Mediator Pattern
• A mediator:
• A neutral party who assists in negotiations and conflict resolution.
• Behavioural design pattern
• Encapsulates how disparate modules interact with each other by acting
as an intermediary
• If a system seems to have too many direct relationships between its modules
(colleagues), it may be time to have a central point of control that modules
communicate through instead.
• A mediator:
• Promotes loose coupling
• Modules can broadcast or listen for notifications without worrying about the
rest of the system
16
JavaScript Design Patterns
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Mediator Pattern
17
JavaScript Design Patterns
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Mediator Pattern
18
JavaScript Design Patterns
var Participant = function(name) {
this.name = name;
this.chatroom = null;
};
Participant.prototype = {
send: function(message, to) {
this.chatroom.send(message, this, to);
},
receive: function(message, from) {
log.add(from.name + " to " + this.name + ": " + message);
}
};
var Chatroom = function() {
var participants = {};
return {
register: function(participant) {
participants[participant.name] = participant;
participant.chatroom = this;
},
send: function(message, from, to) {
if (to) { // single message
to.receive(message, from);
} else { // broadcast message
for (key in participants) {
if (participants[key] !== from) {
participants[key].receive(message, from);
}
}
}
}
};
};
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
Mediator Pattern
19
JavaScript Design Patterns
// log helper
var log = (function() {
var log = "";
return {
add: function(msg) { log += msg + "n"; },
show: function() { alert(log); log = ""; }
}
})();
function run() {
var yoko = new Participant("Yoko");
var john = new Participant("John");
var paul = new Participant("Paul");
var ringo = new Participant("Ringo");
var chatroom = new Chatroom();
chatroom.register(yoko);
chatroom.register(john);
chatroom.register(paul);
chatroom.register(ringo);
yoko.send("All you need is love.");
yoko.send("I love you John.");
john.send("Hey, no need to broadcast", yoko);
paul.send("Ha, I heard that!");
ringo.send("Paul, what do you think?", paul);
log.show();
}
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
PUTTING IT ALL TOGETHER
20
JavaScript Design Patterns
MedTech
Building Large and Complex Applications
• How do Design Patterns help in building a large and complex
application?
• Large-scale JavaScript apps are non-trivial applications requiring
significant developer effort to maintain, where most heavy lifting of
data manipulation and display falls to the browser
• You should dedicate sufficient time to planning the underlying architecture
• Ask yourself these questions about your application:
• How much of your modules are instantly re-usable?
• Can single modules exist on their own independently?
• Can single modules be tested independently?
• How much are your modules coupled?
• If specific parts of your application fail, will it still function?
21
JavaScript Design Patterns
MedTech
Building Large and Complex Applications
« The secret to building large apps is to never build large apps. Break your
applications into small pieces. Then, assemble those testable, bite-sized
pieces into your big application » - Justin Meyer
«  The more tied components are to each other, the less reusable they will
be, and the more difficult it becomes to make changes to one without
accidentally affecting another” - Rebecca Murphey
22
JavaScript Design Patterns
MedTech
Building Large and Complex Applications
• Our objectives
• Loosely coupled architecture
• Functionality broken down into smaller independent modules
• Framework and library agnostic, flexibility to change in the future
• But also:
• Single modules speak to the app when something interesting happens
• An intermediate layer interprets the requests
• Modules can’t access the core directly
• The app shouldn’t fall over due to an error in a specific module
23
JavaScript Design Patterns
MedTech
Building Large and Complex Applications
24
JavaScript Design Patterns
MedTech
Building Large and Complex Applications
• Facade
• Abstraction of the core that sits in the middle between it and the modules
• Ensures a consistent interface to our modules is available at all times
• Should be the only thing modules are aware of
• They shouldn’t know about each other, or about the core application
• Acts as a security guard, determining which part of the application a module can access
• Application core : Manages the modules lifecycle:
• Starts and stops them, restarts them if they fail
• Adds and removes them without breaking anything
• Detects and manages errors of the system
• Modules
• Inform the application when something interesting happens to publish events of interest
• Don’t care about when, where and to whom the notifications are issued
• Aren’t concerned if other modules fail
25
JavaScript Design Patterns
MedTech
Dr. Lilia SFAXI
www.liliasfaxi.wix.com/liliasfaxi
References
26
• M. Haverbeke, Eloquent JavaScript: A modern introduction to
programming, 2014
• Textbook
• A. Osmany, Learning JavaScript Design Patterns, O’Reilly, 2012
Ad

More Related Content

What's hot (20)

Core JavaScript
Core JavaScriptCore JavaScript
Core JavaScript
Lilia Sfaxi
 
Android-Tp3: fragments et menus
Android-Tp3: fragments et menusAndroid-Tp3: fragments et menus
Android-Tp3: fragments et menus
Lilia Sfaxi
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
Emanuele DelBono
 
Cours design pattern m youssfi partie 6 proxy
Cours design pattern m youssfi partie 6 proxyCours design pattern m youssfi partie 6 proxy
Cours design pattern m youssfi partie 6 proxy
ENSET, Université Hassan II Casablanca
 
P4 intents
P4 intentsP4 intents
P4 intents
Lilia Sfaxi
 
Cours design pattern m youssfi partie 3 decorateur
Cours design pattern m youssfi partie 3 decorateurCours design pattern m youssfi partie 3 decorateur
Cours design pattern m youssfi partie 3 decorateur
ENSET, Université Hassan II Casablanca
 
Vue.js
Vue.jsVue.js
Vue.js
Jadson Santos
 
Modele mvc
Modele mvcModele mvc
Modele mvc
Soulef riahi
 
Maven et industrialisation du logiciel
Maven et industrialisation du logicielMaven et industrialisation du logiciel
Maven et industrialisation du logiciel
ENSET, Université Hassan II Casablanca
 
Workshop Spring - Session 1 - L'offre Spring et les bases
Workshop Spring  - Session 1 - L'offre Spring et les basesWorkshop Spring  - Session 1 - L'offre Spring et les bases
Workshop Spring - Session 1 - L'offre Spring et les bases
Antoine Rey
 
Java 8-streams-collectors-patterns
Java 8-streams-collectors-patternsJava 8-streams-collectors-patterns
Java 8-streams-collectors-patterns
José Paumard
 
Mohamed youssfi support architectures logicielles distribuées basées sue les ...
Mohamed youssfi support architectures logicielles distribuées basées sue les ...Mohamed youssfi support architectures logicielles distribuées basées sue les ...
Mohamed youssfi support architectures logicielles distribuées basées sue les ...
ENSET, Université Hassan II Casablanca
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVC
IndicThreads
 
Développement d'un site web jee de e commerce basé sur spring (m.youssfi)
Développement d'un site web jee de e commerce basé sur spring (m.youssfi)Développement d'un site web jee de e commerce basé sur spring (m.youssfi)
Développement d'un site web jee de e commerce basé sur spring (m.youssfi)
ENSET, Université Hassan II Casablanca
 
Android-Tp4: stockage
Android-Tp4: stockageAndroid-Tp4: stockage
Android-Tp4: stockage
Lilia Sfaxi
 
Tp1 - WS avec JAXWS
Tp1 - WS avec JAXWSTp1 - WS avec JAXWS
Tp1 - WS avec JAXWS
Lilia Sfaxi
 
P3 listes et elements graphiques avancés
P3 listes et elements graphiques avancésP3 listes et elements graphiques avancés
P3 listes et elements graphiques avancés
Lilia Sfaxi
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
MicroPyramid .
 
Cours JavaScript
Cours JavaScriptCours JavaScript
Cours JavaScript
Olivier Le Goaër
 
Concevoir, développer et sécuriser des micro-services avec Spring Boot
Concevoir, développer et sécuriser des micro-services avec Spring BootConcevoir, développer et sécuriser des micro-services avec Spring Boot
Concevoir, développer et sécuriser des micro-services avec Spring Boot
DNG Consulting
 
Android-Tp3: fragments et menus
Android-Tp3: fragments et menusAndroid-Tp3: fragments et menus
Android-Tp3: fragments et menus
Lilia Sfaxi
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
Emanuele DelBono
 
Workshop Spring - Session 1 - L'offre Spring et les bases
Workshop Spring  - Session 1 - L'offre Spring et les basesWorkshop Spring  - Session 1 - L'offre Spring et les bases
Workshop Spring - Session 1 - L'offre Spring et les bases
Antoine Rey
 
Java 8-streams-collectors-patterns
Java 8-streams-collectors-patternsJava 8-streams-collectors-patterns
Java 8-streams-collectors-patterns
José Paumard
 
Mohamed youssfi support architectures logicielles distribuées basées sue les ...
Mohamed youssfi support architectures logicielles distribuées basées sue les ...Mohamed youssfi support architectures logicielles distribuées basées sue les ...
Mohamed youssfi support architectures logicielles distribuées basées sue les ...
ENSET, Université Hassan II Casablanca
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVC
IndicThreads
 
Développement d'un site web jee de e commerce basé sur spring (m.youssfi)
Développement d'un site web jee de e commerce basé sur spring (m.youssfi)Développement d'un site web jee de e commerce basé sur spring (m.youssfi)
Développement d'un site web jee de e commerce basé sur spring (m.youssfi)
ENSET, Université Hassan II Casablanca
 
Android-Tp4: stockage
Android-Tp4: stockageAndroid-Tp4: stockage
Android-Tp4: stockage
Lilia Sfaxi
 
Tp1 - WS avec JAXWS
Tp1 - WS avec JAXWSTp1 - WS avec JAXWS
Tp1 - WS avec JAXWS
Lilia Sfaxi
 
P3 listes et elements graphiques avancés
P3 listes et elements graphiques avancésP3 listes et elements graphiques avancés
P3 listes et elements graphiques avancés
Lilia Sfaxi
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
MicroPyramid .
 
Concevoir, développer et sécuriser des micro-services avec Spring Boot
Concevoir, développer et sécuriser des micro-services avec Spring BootConcevoir, développer et sécuriser des micro-services avec Spring Boot
Concevoir, développer et sécuriser des micro-services avec Spring Boot
DNG Consulting
 

Viewers also liked (16)

Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScript
Lilia Sfaxi
 
Angular
AngularAngular
Angular
Lilia Sfaxi
 
Introduction au Web
Introduction au WebIntroduction au Web
Introduction au Web
Lilia Sfaxi
 
Testing Angular
Testing AngularTesting Angular
Testing Angular
Lilia Sfaxi
 
Server-side JS with NodeJS
Server-side JS with NodeJSServer-side JS with NodeJS
Server-side JS with NodeJS
Lilia Sfaxi
 
Mobile developement
Mobile developementMobile developement
Mobile developement
Lilia Sfaxi
 
BigData_TP5 : Neo4J
BigData_TP5 : Neo4JBigData_TP5 : Neo4J
BigData_TP5 : Neo4J
Lilia Sfaxi
 
BigData_TP4 : Cassandra
BigData_TP4 : CassandraBigData_TP4 : Cassandra
BigData_TP4 : Cassandra
Lilia Sfaxi
 
BigData_TP2: Design Patterns dans Hadoop
BigData_TP2: Design Patterns dans HadoopBigData_TP2: Design Patterns dans Hadoop
BigData_TP2: Design Patterns dans Hadoop
Lilia Sfaxi
 
BigData_TP1: Initiation à Hadoop et Map-Reduce
BigData_TP1: Initiation à Hadoop et Map-ReduceBigData_TP1: Initiation à Hadoop et Map-Reduce
BigData_TP1: Initiation à Hadoop et Map-Reduce
Lilia Sfaxi
 
BigData_TP3 : Spark
BigData_TP3 : SparkBigData_TP3 : Spark
BigData_TP3 : Spark
Lilia Sfaxi
 
BigData_Chp4: NOSQL
BigData_Chp4: NOSQLBigData_Chp4: NOSQL
BigData_Chp4: NOSQL
Lilia Sfaxi
 
BigData_Chp3: Data Processing
BigData_Chp3: Data ProcessingBigData_Chp3: Data Processing
BigData_Chp3: Data Processing
Lilia Sfaxi
 
BigData_Chp5: Putting it all together
BigData_Chp5: Putting it all togetherBigData_Chp5: Putting it all together
BigData_Chp5: Putting it all together
Lilia Sfaxi
 
BigData_Chp2: Hadoop & Map-Reduce
BigData_Chp2: Hadoop & Map-ReduceBigData_Chp2: Hadoop & Map-Reduce
BigData_Chp2: Hadoop & Map-Reduce
Lilia Sfaxi
 
BigData_Chp1: Introduction à la Big Data
BigData_Chp1: Introduction à la Big DataBigData_Chp1: Introduction à la Big Data
BigData_Chp1: Introduction à la Big Data
Lilia Sfaxi
 
Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScript
Lilia Sfaxi
 
Introduction au Web
Introduction au WebIntroduction au Web
Introduction au Web
Lilia Sfaxi
 
Server-side JS with NodeJS
Server-side JS with NodeJSServer-side JS with NodeJS
Server-side JS with NodeJS
Lilia Sfaxi
 
Mobile developement
Mobile developementMobile developement
Mobile developement
Lilia Sfaxi
 
BigData_TP5 : Neo4J
BigData_TP5 : Neo4JBigData_TP5 : Neo4J
BigData_TP5 : Neo4J
Lilia Sfaxi
 
BigData_TP4 : Cassandra
BigData_TP4 : CassandraBigData_TP4 : Cassandra
BigData_TP4 : Cassandra
Lilia Sfaxi
 
BigData_TP2: Design Patterns dans Hadoop
BigData_TP2: Design Patterns dans HadoopBigData_TP2: Design Patterns dans Hadoop
BigData_TP2: Design Patterns dans Hadoop
Lilia Sfaxi
 
BigData_TP1: Initiation à Hadoop et Map-Reduce
BigData_TP1: Initiation à Hadoop et Map-ReduceBigData_TP1: Initiation à Hadoop et Map-Reduce
BigData_TP1: Initiation à Hadoop et Map-Reduce
Lilia Sfaxi
 
BigData_TP3 : Spark
BigData_TP3 : SparkBigData_TP3 : Spark
BigData_TP3 : Spark
Lilia Sfaxi
 
BigData_Chp4: NOSQL
BigData_Chp4: NOSQLBigData_Chp4: NOSQL
BigData_Chp4: NOSQL
Lilia Sfaxi
 
BigData_Chp3: Data Processing
BigData_Chp3: Data ProcessingBigData_Chp3: Data Processing
BigData_Chp3: Data Processing
Lilia Sfaxi
 
BigData_Chp5: Putting it all together
BigData_Chp5: Putting it all togetherBigData_Chp5: Putting it all together
BigData_Chp5: Putting it all together
Lilia Sfaxi
 
BigData_Chp2: Hadoop & Map-Reduce
BigData_Chp2: Hadoop & Map-ReduceBigData_Chp2: Hadoop & Map-Reduce
BigData_Chp2: Hadoop & Map-Reduce
Lilia Sfaxi
 
BigData_Chp1: Introduction à la Big Data
BigData_Chp1: Introduction à la Big DataBigData_Chp1: Introduction à la Big Data
BigData_Chp1: Introduction à la Big Data
Lilia Sfaxi
 
Ad

Similar to Javascript Design Patterns (20)

Java Design Patterns Interview Questions PDF By ScholarHat
Java Design Patterns Interview Questions PDF By ScholarHatJava Design Patterns Interview Questions PDF By ScholarHat
Java Design Patterns Interview Questions PDF By ScholarHat
Scholarhat
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Luis Valencia
 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
Gaurav Tyagi
 
Gang of Four in Java
Gang of Four in Java Gang of Four in Java
Gang of Four in Java
Mina Tafreshi
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
Rafael Coutinho
 
Oops design pattern intro
Oops design pattern intro Oops design pattern intro
Oops design pattern intro
anshu_atri
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
danhaley45372
 
JS Design patterns in Web technologies including oop techniques.pptx
JS Design patterns in Web technologies including oop techniques.pptxJS Design patterns in Web technologies including oop techniques.pptx
JS Design patterns in Web technologies including oop techniques.pptx
husnainali397602
 
Building Scalable JavaScript Apps
Building Scalable JavaScript AppsBuilding Scalable JavaScript Apps
Building Scalable JavaScript Apps
Gil Fink
 
Design patterns
Design patternsDesign patterns
Design patterns
Akhilesh Joshi
 
Introduction to design_patterns
Introduction to design_patternsIntroduction to design_patterns
Introduction to design_patterns
amitarcade
 
Александр Белецкий "Архитектура Javascript приложений"
 Александр Белецкий "Архитектура Javascript приложений" Александр Белецкий "Архитектура Javascript приложений"
Александр Белецкий "Архитектура Javascript приложений"
Agile Base Camp
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
naveen kumar
 
Chapter15-Presentation.pptx
Chapter15-Presentation.pptxChapter15-Presentation.pptx
Chapter15-Presentation.pptx
GFRomano
 
Handlebars and Require.js
Handlebars and Require.jsHandlebars and Require.js
Handlebars and Require.js
Ivano Malavolta
 
jquery summit presentation for large scale javascript applications
jquery summit  presentation for large scale javascript applicationsjquery summit  presentation for large scale javascript applications
jquery summit presentation for large scale javascript applications
DivyanshGupta922023
 
Design pattern of software words computer .pptx
Design pattern of software words computer .pptxDesign pattern of software words computer .pptx
Design pattern of software words computer .pptx
muslimpari2503
 
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Steven Smith
 
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjsCodemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Fabio Franzini
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
Ayush Sharma
 
Java Design Patterns Interview Questions PDF By ScholarHat
Java Design Patterns Interview Questions PDF By ScholarHatJava Design Patterns Interview Questions PDF By ScholarHat
Java Design Patterns Interview Questions PDF By ScholarHat
Scholarhat
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Luis Valencia
 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
Gaurav Tyagi
 
Gang of Four in Java
Gang of Four in Java Gang of Four in Java
Gang of Four in Java
Mina Tafreshi
 
Oops design pattern intro
Oops design pattern intro Oops design pattern intro
Oops design pattern intro
anshu_atri
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
danhaley45372
 
JS Design patterns in Web technologies including oop techniques.pptx
JS Design patterns in Web technologies including oop techniques.pptxJS Design patterns in Web technologies including oop techniques.pptx
JS Design patterns in Web technologies including oop techniques.pptx
husnainali397602
 
Building Scalable JavaScript Apps
Building Scalable JavaScript AppsBuilding Scalable JavaScript Apps
Building Scalable JavaScript Apps
Gil Fink
 
Introduction to design_patterns
Introduction to design_patternsIntroduction to design_patterns
Introduction to design_patterns
amitarcade
 
Александр Белецкий "Архитектура Javascript приложений"
 Александр Белецкий "Архитектура Javascript приложений" Александр Белецкий "Архитектура Javascript приложений"
Александр Белецкий "Архитектура Javascript приложений"
Agile Base Camp
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
naveen kumar
 
Chapter15-Presentation.pptx
Chapter15-Presentation.pptxChapter15-Presentation.pptx
Chapter15-Presentation.pptx
GFRomano
 
Handlebars and Require.js
Handlebars and Require.jsHandlebars and Require.js
Handlebars and Require.js
Ivano Malavolta
 
jquery summit presentation for large scale javascript applications
jquery summit  presentation for large scale javascript applicationsjquery summit  presentation for large scale javascript applications
jquery summit presentation for large scale javascript applications
DivyanshGupta922023
 
Design pattern of software words computer .pptx
Design pattern of software words computer .pptxDesign pattern of software words computer .pptx
Design pattern of software words computer .pptx
muslimpari2503
 
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Steven Smith
 
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjsCodemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Fabio Franzini
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
Ayush Sharma
 
Ad

More from Lilia Sfaxi (20)

chp1-Intro à l'urbanisation des SI.pdf
chp1-Intro à l'urbanisation des SI.pdfchp1-Intro à l'urbanisation des SI.pdf
chp1-Intro à l'urbanisation des SI.pdf
Lilia Sfaxi
 
Plan d'études_INSAT_2022_2023.pdf
Plan d'études_INSAT_2022_2023.pdfPlan d'études_INSAT_2022_2023.pdf
Plan d'études_INSAT_2022_2023.pdf
Lilia Sfaxi
 
Lab3-DB_Neo4j
Lab3-DB_Neo4jLab3-DB_Neo4j
Lab3-DB_Neo4j
Lilia Sfaxi
 
Lab2-DB-Mongodb
Lab2-DB-MongodbLab2-DB-Mongodb
Lab2-DB-Mongodb
Lilia Sfaxi
 
Lab1-DB-Cassandra
Lab1-DB-CassandraLab1-DB-Cassandra
Lab1-DB-Cassandra
Lilia Sfaxi
 
TP2-UML-Correction
TP2-UML-CorrectionTP2-UML-Correction
TP2-UML-Correction
Lilia Sfaxi
 
TP1-UML-Correction
TP1-UML-CorrectionTP1-UML-Correction
TP1-UML-Correction
Lilia Sfaxi
 
TP0-UML-Correction
TP0-UML-CorrectionTP0-UML-Correction
TP0-UML-Correction
Lilia Sfaxi
 
TD4-UML
TD4-UMLTD4-UML
TD4-UML
Lilia Sfaxi
 
TD4-UML-Correction
TD4-UML-CorrectionTD4-UML-Correction
TD4-UML-Correction
Lilia Sfaxi
 
TD3-UML-Séquences
TD3-UML-SéquencesTD3-UML-Séquences
TD3-UML-Séquences
Lilia Sfaxi
 
TD3-UML-Correction
TD3-UML-CorrectionTD3-UML-Correction
TD3-UML-Correction
Lilia Sfaxi
 
TD2 - UML - Correction
TD2 - UML - CorrectionTD2 - UML - Correction
TD2 - UML - Correction
Lilia Sfaxi
 
TD1 - UML - DCU
TD1 - UML - DCUTD1 - UML - DCU
TD1 - UML - DCU
Lilia Sfaxi
 
TD1-UML-correction
TD1-UML-correctionTD1-UML-correction
TD1-UML-correction
Lilia Sfaxi
 
Android - Tp1 - installation et démarrage
Android - Tp1 -   installation et démarrageAndroid - Tp1 -   installation et démarrage
Android - Tp1 - installation et démarrage
Lilia Sfaxi
 
Android - Tp2 - Elements graphiques
Android - Tp2 - Elements graphiques Android - Tp2 - Elements graphiques
Android - Tp2 - Elements graphiques
Lilia Sfaxi
 
Android - Tp3 - intents
Android - Tp3 -  intentsAndroid - Tp3 -  intents
Android - Tp3 - intents
Lilia Sfaxi
 
Android - TPBonus - web services
Android - TPBonus - web servicesAndroid - TPBonus - web services
Android - TPBonus - web services
Lilia Sfaxi
 
Android - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancésAndroid - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancés
Lilia Sfaxi
 
chp1-Intro à l'urbanisation des SI.pdf
chp1-Intro à l'urbanisation des SI.pdfchp1-Intro à l'urbanisation des SI.pdf
chp1-Intro à l'urbanisation des SI.pdf
Lilia Sfaxi
 
Plan d'études_INSAT_2022_2023.pdf
Plan d'études_INSAT_2022_2023.pdfPlan d'études_INSAT_2022_2023.pdf
Plan d'études_INSAT_2022_2023.pdf
Lilia Sfaxi
 
Lab1-DB-Cassandra
Lab1-DB-CassandraLab1-DB-Cassandra
Lab1-DB-Cassandra
Lilia Sfaxi
 
TP2-UML-Correction
TP2-UML-CorrectionTP2-UML-Correction
TP2-UML-Correction
Lilia Sfaxi
 
TP1-UML-Correction
TP1-UML-CorrectionTP1-UML-Correction
TP1-UML-Correction
Lilia Sfaxi
 
TP0-UML-Correction
TP0-UML-CorrectionTP0-UML-Correction
TP0-UML-Correction
Lilia Sfaxi
 
TD4-UML-Correction
TD4-UML-CorrectionTD4-UML-Correction
TD4-UML-Correction
Lilia Sfaxi
 
TD3-UML-Séquences
TD3-UML-SéquencesTD3-UML-Séquences
TD3-UML-Séquences
Lilia Sfaxi
 
TD3-UML-Correction
TD3-UML-CorrectionTD3-UML-Correction
TD3-UML-Correction
Lilia Sfaxi
 
TD2 - UML - Correction
TD2 - UML - CorrectionTD2 - UML - Correction
TD2 - UML - Correction
Lilia Sfaxi
 
TD1-UML-correction
TD1-UML-correctionTD1-UML-correction
TD1-UML-correction
Lilia Sfaxi
 
Android - Tp1 - installation et démarrage
Android - Tp1 -   installation et démarrageAndroid - Tp1 -   installation et démarrage
Android - Tp1 - installation et démarrage
Lilia Sfaxi
 
Android - Tp2 - Elements graphiques
Android - Tp2 - Elements graphiques Android - Tp2 - Elements graphiques
Android - Tp2 - Elements graphiques
Lilia Sfaxi
 
Android - Tp3 - intents
Android - Tp3 -  intentsAndroid - Tp3 -  intents
Android - Tp3 - intents
Lilia Sfaxi
 
Android - TPBonus - web services
Android - TPBonus - web servicesAndroid - TPBonus - web services
Android - TPBonus - web services
Lilia Sfaxi
 
Android - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancésAndroid - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancés
Lilia Sfaxi
 

Recently uploaded (20)

ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 

Javascript Design Patterns

  • 1. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Chp4- JavaScript Design Patterns Design Patterns 1 MedTech – Mediterranean Institute of Technology CS-Web and Mobile Development MedTech
  • 2. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi What is a Pattern? • A pattern is a reusable solution that can be applied to commonly occurring problems in software design • In our case, in writing JavaScript web applications. • Sorts of templates for how we solve problems - ones which can be used in quite a few different situations. • Three main benefits • Patterns are proven solutions: They provide solid approaches to solving issues in software development using proven techniques that reflect the experience and insights the developers that helped define them bring to the pattern. • Patterns can be easily reused: A pattern usually reflects an out of the box solution that can be adapted to suit our own needs. This feature makes them quite robust. • Patterns can be expressive: When we look at a pattern there’s generally a set structure and vocabulary to the solution presented that can help express rather large solutions quite elegantly. 2 JavaScript Design Patterns
  • 3. MedTech JavaScript Design Patterns Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Summary of Design Patterns 3 Class Factory Method This makes an instance of several derived classes based on interfaced data or events. Object Abstract Factory Creates an instance of several families of classes without detailing concrete classes. Builder Separates object construction from its representation, always creates the same type of object. Prototype A fully initialized instance used for copying or cloning. Singleton A class with only a single instance with global access points. Creational: Based on the concept of creating an object
  • 4. MedTech JavaScript Design Patterns Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Summary of Design Patterns 4 Class Adapter Match interfaces of different classes therefore classes can work together despite incompatible interfaces. (uses inheritance) Object Adapter Match interfaces of different classes therefore classes can work together despite incompatible interfaces. (uses composition) Bridge Separates an object's interface from its implementation so the two can vary independently. Composite A structure of simple and composite objects which makes the total object more than just the sum of its parts. Decorator Dynamically add alternate processing to objects. Façade A single class that hides the complexity of an entire subsystem. Flyweight A fine-grained instance used for efficient sharing of information that is contained elsewhere. Proxy A place holder object representing the true object. Structural: Based on the idea of building blocks of objects.
  • 5. MedTech JavaScript Design Patterns Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Summary of Design Patterns 5 Class Interpreter A way to include language elements in an application to match the grammar of the intended language. Template Method Creates the shell of an algorithm in a method, then defer the exact steps to a subclass. Object Chain of Responsibility A way of passing a request between a chain of objects to find the object that can handle the request. Command Encapsulate a command request as an object to enable, logging and/or queuing of requests, and provides error- handling for unhandled requests. Iterator Sequentially access the elements of a collection without knowing the inner workings of the collection. Mediator Defines simplified communication between classes to prevent a group of classes from referring explicitly to each other. Memento Capture an object's internal state to be able to restore it later. Observer A way of notifying change to a number of classes to ensure consistency between the classes. State Alter an object's behavior when its state changes. Strategy Encapsulates an algorithm inside a class separating the selection from the implementation. Visitor Adds a new operation to a class without changing the class. Behavioral: Based on the way objects play and work together
  • 6. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi JS PATTERNS 6 JavaScript Design Patterns
  • 7. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Creational Pattern • Deals with the creation of new objects • Basically three ways to create objects: • var newObject = {}; • var newObject = Object.create(null); • var newObject = new Object(); • And four ways to assign a value to an object 1. Dot Syntax • newObject.someKey = 'Hello World'; // Write properties • var key = newObject.someKey; // Access properties 2. Square Brackets Syntax • newObject['someKey'] = 'Hello World';// Write properties • var key = newObject['someKey']; // Access properties 7 JavaScript Design Patterns
  • 8. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Creational Pattern 3. defineProperty Object.defineProperty(newObject, "someKey", { value: "for more control of the property's behavior", writable: true, enumerable: true, configurable: true }); 5. defineProperties Object.defineProperties(newObject, { "someKey": { value: "Hello World", writable: true }, "anotherKey": { value: "Foo bar", writable: false } }); 8 JavaScript Design Patterns
  • 9. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Constructor Pattern • Basic Constructors 9 JavaScript Design Patterns function Car(model, year, miles) { this.model = model; this.year = year; this.miles = miles; this.toString = function () { return this.model + " has done " + this.miles + " miles"; }; } var civic = new Car("Honda Civic", 2009, 20000); var mondeo = new Car("Ford Mondeo", 2010, 5000); console.log(civic.toString()); console.log(mondeo.toString());
  • 10. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Constructor Pattern • Constructors with Prototype 10 JavaScript Design Patterns function Car(model, year, miles) { this.model = model; this.year = year; this.miles = miles; } Car.prototype.toString = function () { return this.model + " has done " + this.miles + " miles"; }; var civic = new Car("Honda Civic", 2009, 20000); var mondeo = new Car("Ford Mondeo", 2010, 5000); console.log(civic.toString()); console.log(mondeo.toString());
  • 11. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Module Pattern • Module • Interchangeable single-part of a larger system that can be easily reused • Using the notion of IIFE: Immediately Invoked Function Expressions (function() { // code to be immediately invoked }()); • Problem: there is no real privacy in JavaScript • The typical module pattern is where immediately invoked function expressions (IIFEs) use execution context to create ‘privacy’ • Here, objects are returned instead of functions. • In the pattern • Variables declared are only available inside the module. • Variables defined within the returning object are available to everyone 11 JavaScript Design Patterns
  • 12. MedTech JavaScript Design Patterns Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Module Pattern 12 var basketModule = (function() { var basket = []; //private return { //exposed to public addItem: function(values) { basket.push(values); }, getItemCount: function() { return basket.length; }, getTotal: function(){ var q = this.getItemCount(), p=0; while(q--){ p+= basket[q].price; } return p; } } }());
  • 13. MedTech JavaScript Design Patterns Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Module Pattern 13 //basketModule is an object with properties which can also be methods basketModule.addItem({item:'bread',price:0.5}); basketModule.addItem({item:'butter',price:0.3}); console.log(basketModule.getItemCount()); console.log(basketModule.getTotal()); //however, the following will not work: // (undefined as not inside the returned object) console.log(basketModule.basket); //error! //(only possible within the module scope) console.log(basket); //error
  • 14. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Façade Pattern • Structural Pattern • Convenient, high-level interfaces to larger bodies of code that hide underlying complexity • Aims to simplify the presented API to other developers • The facade pattern : • Simplifies the interface of a class • Decouples the class from the code that uses it • Facades can be used with the Module pattern in order to hide its methods • It differs from the Module pattern as the limited public API differs greatly from the reality of the implementation. 14 JavaScript Design Patterns
  • 15. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Façade Pattern 15 JavaScript Design Patterns var module = (function() { var _private = { i:5, get : function() { console.log('current value:' + this.i); }, set : function( val ) { this.i = val; }, run : function() { console.log('running'); }, jump: function(){ console.log('jumping'); } }; return { facade : function( args ) { _private.set(args.val); _private.get(); if ( args.run ) { _private.run(); } } } }()); module.facade({run: true, val:10}); //outputs current value: 10, running
  • 16. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Mediator Pattern • A mediator: • A neutral party who assists in negotiations and conflict resolution. • Behavioural design pattern • Encapsulates how disparate modules interact with each other by acting as an intermediary • If a system seems to have too many direct relationships between its modules (colleagues), it may be time to have a central point of control that modules communicate through instead. • A mediator: • Promotes loose coupling • Modules can broadcast or listen for notifications without worrying about the rest of the system 16 JavaScript Design Patterns
  • 18. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Mediator Pattern 18 JavaScript Design Patterns var Participant = function(name) { this.name = name; this.chatroom = null; }; Participant.prototype = { send: function(message, to) { this.chatroom.send(message, this, to); }, receive: function(message, from) { log.add(from.name + " to " + this.name + ": " + message); } }; var Chatroom = function() { var participants = {}; return { register: function(participant) { participants[participant.name] = participant; participant.chatroom = this; }, send: function(message, from, to) { if (to) { // single message to.receive(message, from); } else { // broadcast message for (key in participants) { if (participants[key] !== from) { participants[key].receive(message, from); } } } } }; };
  • 19. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi Mediator Pattern 19 JavaScript Design Patterns // log helper var log = (function() { var log = ""; return { add: function(msg) { log += msg + "n"; }, show: function() { alert(log); log = ""; } } })(); function run() { var yoko = new Participant("Yoko"); var john = new Participant("John"); var paul = new Participant("Paul"); var ringo = new Participant("Ringo"); var chatroom = new Chatroom(); chatroom.register(yoko); chatroom.register(john); chatroom.register(paul); chatroom.register(ringo); yoko.send("All you need is love."); yoko.send("I love you John."); john.send("Hey, no need to broadcast", yoko); paul.send("Ha, I heard that!"); ringo.send("Paul, what do you think?", paul); log.show(); }
  • 20. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi PUTTING IT ALL TOGETHER 20 JavaScript Design Patterns
  • 21. MedTech Building Large and Complex Applications • How do Design Patterns help in building a large and complex application? • Large-scale JavaScript apps are non-trivial applications requiring significant developer effort to maintain, where most heavy lifting of data manipulation and display falls to the browser • You should dedicate sufficient time to planning the underlying architecture • Ask yourself these questions about your application: • How much of your modules are instantly re-usable? • Can single modules exist on their own independently? • Can single modules be tested independently? • How much are your modules coupled? • If specific parts of your application fail, will it still function? 21 JavaScript Design Patterns
  • 22. MedTech Building Large and Complex Applications « The secret to building large apps is to never build large apps. Break your applications into small pieces. Then, assemble those testable, bite-sized pieces into your big application » - Justin Meyer «  The more tied components are to each other, the less reusable they will be, and the more difficult it becomes to make changes to one without accidentally affecting another” - Rebecca Murphey 22 JavaScript Design Patterns
  • 23. MedTech Building Large and Complex Applications • Our objectives • Loosely coupled architecture • Functionality broken down into smaller independent modules • Framework and library agnostic, flexibility to change in the future • But also: • Single modules speak to the app when something interesting happens • An intermediate layer interprets the requests • Modules can’t access the core directly • The app shouldn’t fall over due to an error in a specific module 23 JavaScript Design Patterns
  • 24. MedTech Building Large and Complex Applications 24 JavaScript Design Patterns
  • 25. MedTech Building Large and Complex Applications • Facade • Abstraction of the core that sits in the middle between it and the modules • Ensures a consistent interface to our modules is available at all times • Should be the only thing modules are aware of • They shouldn’t know about each other, or about the core application • Acts as a security guard, determining which part of the application a module can access • Application core : Manages the modules lifecycle: • Starts and stops them, restarts them if they fail • Adds and removes them without breaking anything • Detects and manages errors of the system • Modules • Inform the application when something interesting happens to publish events of interest • Don’t care about when, where and to whom the notifications are issued • Aren’t concerned if other modules fail 25 JavaScript Design Patterns
  • 26. MedTech Dr. Lilia SFAXI www.liliasfaxi.wix.com/liliasfaxi References 26 • M. Haverbeke, Eloquent JavaScript: A modern introduction to programming, 2014 • Textbook • A. Osmany, Learning JavaScript Design Patterns, O’Reilly, 2012