SlideShare a Scribd company logo
Design Pattern in an
Expressive Language
JavaScript
Design Pattern
Agenda
★ JavaScript Summary
★ What? Why? How?
★ Anti Pattern
★ Constructor Pattern
★ Module Pattern
★ Revealing Module Pattern
★ Facade Pattern
★ Promise Deferred Pattern
★ Decorator Pattern
About Me
Amit Thakkar
Tech Blogger @ CodeChutney.in
JavaScript Lover
Working on MEAN Stack
Twitter: @amit_thakkar01
LinkedIn: linkedin.com/in/amitthakkar01
Facebook: facebook.com/amit.thakkar01
This session is targeted at professional developers
wishing to improve their knowledge of design
patterns and want to learn how to write beautiful,
structured and organized code with JavaScript
Programming Language.
Target Audience
JavaScript Summary
1. Everything is an Object
2. Loose Typing
3. Decent DOM API
4. Asynchronicity
What?
They are reusable solutions to commonly
occurring problems in software design. Or we can
say they are as templates for how we solve
problems.
They help us build upon the combined experience
of many developers that came before us and
ensure we structure our code in an optimized way,
meeting the needs of problems we’re attempting to
solve.
Why?
How?
1. They are proven solutions.
2. They are like component so can be easily
reused.
3. They are common for all languages
Anti Patterns
1. Polluting the global object.
2. Passing strings rather than function to either
setTimeout or setInterval.
3. Modifying the Object class prototype.
4. Using JavaScript in an inline form as this is
inflexible.
Constructor Patterns
JavaScript doesn't support the concept of classes
but it does support special constructor functions
that work with objects. By simply prefixing a call to
a constructor function with the keyword "new", we
can tell JavaScript we would like the function to
behave like a constructor and instantiate a new
object with the members defined by that function.
Inside a constructor, the keyword this references
the new object that's being created.
You can checkout Demo form:
https://github.com/AmitThakkar/JavaScriptDesignPattern
Module Patterns
The Module pattern was originally defined as a
way to provide both private and public
encapsulation for classes. Modules are an integral
piece of any robust application's architecture.
You can checkout Demo form:
https://github.com/AmitThakkar/JavaScriptDesignPattern
Exercise Time
You can exercise form:
https://github.com/AmitThakkar/JavaScriptDesignPattern
Revealing Module Patterns
In Module Pattern, we have to move function into
object hash which we wished to make public. This
pattern is improved version of Module pattern. In
this pattern, we define all of our functions and
variables in the private scope and return an
anonymous object with pointers to the private
functionality we wished to reveal as public.
You can checkout Demo form:
https://github.com/AmitThakkar/JavaScriptDesignPattern
Facade Patterns
This pattern provides a convenient higher-level
interface to a larger body of code or may support
methods with a wide range of behaviors, hiding its
true underlying complexity.
You can checkout Demo form:
https://github.com/AmitThakkar/JavaScriptDesignPattern
Example : 1
var addMyEvent = function( el,ev,fn ){
if( el.addEventListener ){
el.addEventListener( ev,fn, false );
}else if(el.attachEvent){
el.attachEvent( "on" + ev, fn );
} else{
el["on" + ev] = fn;
}
};
Example : 2
bindReady: function() {
if ( document.addEventListener ) {
// Use the handy event callback
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
// A fallback to window.onload, that will always work
window.addEventListener( "load", jQuery.ready, false );
// If IE event model is used
} else if ( document.attachEvent ) {
document.attachEvent( "onreadystatechange", DOMContentLoaded );
// A fallback to window.onload, that will always work
window.attachEvent( "onload", jQuery.ready );
Promise Deferred
Patterns
In the not too distant past the primary tool
available to JavaScript programmers for handling
asynchronous events was the callback.
You can checkout Demo form:
https://github.com/AmitThakkar/JavaScriptDesignPattern
Exercise Time
You can exercise form:
https://github.com/AmitThakkar/JavaScriptDesignPattern
Decorator/Wrapper
Patterns
It allows behavior to be added to an individual
object, either statically or dynamically.
You can checkout Demo form:
https://github.com/AmitThakkar/JavaScriptDesignPattern
Questions??
Question Answer??
Design pattern in an expressive language java script

More Related Content

What's hot (9)

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
John Blanco
 
How I ended up contributing to Magento core
How I ended up contributing to Magento coreHow I ended up contributing to Magento core
How I ended up contributing to Magento core
Alessandro Ronchi
 
How do i implement command design pattern in the java programming course with...
How do i implement command design pattern in the java programming course with...How do i implement command design pattern in the java programming course with...
How do i implement command design pattern in the java programming course with...
kritikumar16
 
How do i implement command design pattern in the java programming course with...
How do i implement command design pattern in the java programming course with...How do i implement command design pattern in the java programming course with...
How do i implement command design pattern in the java programming course with...
kritikumar16
 
Thirty months of microservices. Stairway to heaven or highway to hell? - Sand...
Thirty months of microservices. Stairway to heaven or highway to hell? - Sand...Thirty months of microservices. Stairway to heaven or highway to hell? - Sand...
Thirty months of microservices. Stairway to heaven or highway to hell? - Sand...
Codemotion
 
Clean code
Clean codeClean code
Clean code
NadiiaVlasenko
 
Best Practices For Writing Super Readable Code
Best Practices For Writing Super Readable CodeBest Practices For Writing Super Readable Code
Best Practices For Writing Super Readable Code
AnsviaLab
 
Pcs global (4)
Pcs global (4)Pcs global (4)
Pcs global (4)
Suraj Soni
 
Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1
Mohamed Essam
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
John Blanco
 
How I ended up contributing to Magento core
How I ended up contributing to Magento coreHow I ended up contributing to Magento core
How I ended up contributing to Magento core
Alessandro Ronchi
 
How do i implement command design pattern in the java programming course with...
How do i implement command design pattern in the java programming course with...How do i implement command design pattern in the java programming course with...
How do i implement command design pattern in the java programming course with...
kritikumar16
 
How do i implement command design pattern in the java programming course with...
How do i implement command design pattern in the java programming course with...How do i implement command design pattern in the java programming course with...
How do i implement command design pattern in the java programming course with...
kritikumar16
 
Thirty months of microservices. Stairway to heaven or highway to hell? - Sand...
Thirty months of microservices. Stairway to heaven or highway to hell? - Sand...Thirty months of microservices. Stairway to heaven or highway to hell? - Sand...
Thirty months of microservices. Stairway to heaven or highway to hell? - Sand...
Codemotion
 
Best Practices For Writing Super Readable Code
Best Practices For Writing Super Readable CodeBest Practices For Writing Super Readable Code
Best Practices For Writing Super Readable Code
AnsviaLab
 
Pcs global (4)
Pcs global (4)Pcs global (4)
Pcs global (4)
Suraj Soni
 
Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1
Mohamed Essam
 

Viewers also liked (6)

Javascript essential-pattern
Javascript essential-patternJavascript essential-pattern
Javascript essential-pattern
偉格 高
 
node ffi
node ffinode ffi
node ffi
偉格 高
 
dig2know _offer
dig2know _offerdig2know _offer
dig2know _offer
Vikash Raj
 
Javascript Common Design Patterns
Javascript Common Design PatternsJavascript Common Design Patterns
Javascript Common Design Patterns
Pham Huy Tung
 
Resume_vikash_new_updated_5
Resume_vikash_new_updated_5Resume_vikash_new_updated_5
Resume_vikash_new_updated_5
Vikash Raj
 
Hrd No 5 Offer Letter Sample
Hrd No 5 Offer Letter SampleHrd No 5 Offer Letter Sample
Hrd No 5 Offer Letter Sample
Confidential
 
Javascript essential-pattern
Javascript essential-patternJavascript essential-pattern
Javascript essential-pattern
偉格 高
 
dig2know _offer
dig2know _offerdig2know _offer
dig2know _offer
Vikash Raj
 
Javascript Common Design Patterns
Javascript Common Design PatternsJavascript Common Design Patterns
Javascript Common Design Patterns
Pham Huy Tung
 
Resume_vikash_new_updated_5
Resume_vikash_new_updated_5Resume_vikash_new_updated_5
Resume_vikash_new_updated_5
Vikash Raj
 
Hrd No 5 Offer Letter Sample
Hrd No 5 Offer Letter SampleHrd No 5 Offer Letter Sample
Hrd No 5 Offer Letter Sample
Confidential
 
Ad

Similar to Design pattern in an expressive language java script (20)

Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
Ayush Sharma
 
Javascript design patterns
Javascript design patternsJavascript design patterns
Javascript design patterns
GomathiNayagam S
 
Design patterns in java script, jquery, angularjs
Design patterns in java script, jquery, angularjsDesign patterns in java script, jquery, angularjs
Design patterns in java script, jquery, angularjs
Ravi Bhadauria
 
"The JavaScript Design Patterns You have to Know" by Rashad Majali
"The JavaScript Design Patterns You have to Know" by Rashad Majali"The JavaScript Design Patterns You have to Know" by Rashad Majali
"The JavaScript Design Patterns You have to Know" by Rashad Majali
Jordan Open Source Association
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Lilia Sfaxi
 
JavaScripters Event Sep 17, 2016 · 2:00 PM: Scalable Javascript Design Patterns
JavaScripters Event Sep 17, 2016 · 2:00 PM: Scalable Javascript Design PatternsJavaScripters Event Sep 17, 2016 · 2:00 PM: Scalable Javascript Design Patterns
JavaScripters Event Sep 17, 2016 · 2:00 PM: Scalable Javascript Design Patterns
JavaScripters Community
 
Design pattern
Design patternDesign pattern
Design pattern
Shreyance Jain
 
Patterns In-Javascript
Patterns In-JavascriptPatterns In-Javascript
Patterns In-Javascript
Mindfire Solutions
 
Scalable JavaScript Design Patterns
Scalable JavaScript Design PatternsScalable JavaScript Design Patterns
Scalable JavaScript Design Patterns
Addy Osmani
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Subramanyan Murali
 
Introduction to Design Patterns in Javascript
Introduction to Design Patterns in JavascriptIntroduction to Design Patterns in Javascript
Introduction to Design Patterns in Javascript
Santhosh Kumar Srinivasan
 
JavaScript design patterns introduction
JavaScript design patterns introductionJavaScript design patterns introduction
JavaScript design patterns introduction
D Balaji
 
Introduction to JavaScript design patterns
Introduction to JavaScript design patternsIntroduction to JavaScript design patterns
Introduction to JavaScript design patterns
Jeremy Duvall
 
Design pattern in js
Design pattern in jsDesign pattern in js
Design pattern in js
Anil Kumar Suryavansi
 
Unleashing the Power of Modern Javascript Development
Unleashing the Power of Modern Javascript DevelopmentUnleashing the Power of Modern Javascript Development
Unleashing the Power of Modern Javascript Development
Tarandeep Singh
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Iván Fernández Perea
 
Future-proofing Your JavaScript Apps (Compact edition)
Future-proofing Your JavaScript Apps (Compact edition)Future-proofing Your JavaScript Apps (Compact edition)
Future-proofing Your JavaScript Apps (Compact edition)
Addy Osmani
 
Presenter deck icenium hol
Presenter deck   icenium holPresenter deck   icenium hol
Presenter deck icenium hol
Dhananjay Kumar
 
JavaScript Design Patterns
JavaScript Design PatternsJavaScript Design Patterns
JavaScript Design Patterns
Derek Brown
 
Patterns in JavaScript
Patterns in JavaScriptPatterns in JavaScript
Patterns in JavaScript
Dhananjay Kumar
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
Ayush Sharma
 
Javascript design patterns
Javascript design patternsJavascript design patterns
Javascript design patterns
GomathiNayagam S
 
Design patterns in java script, jquery, angularjs
Design patterns in java script, jquery, angularjsDesign patterns in java script, jquery, angularjs
Design patterns in java script, jquery, angularjs
Ravi Bhadauria
 
"The JavaScript Design Patterns You have to Know" by Rashad Majali
"The JavaScript Design Patterns You have to Know" by Rashad Majali"The JavaScript Design Patterns You have to Know" by Rashad Majali
"The JavaScript Design Patterns You have to Know" by Rashad Majali
Jordan Open Source Association
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Lilia Sfaxi
 
JavaScripters Event Sep 17, 2016 · 2:00 PM: Scalable Javascript Design Patterns
JavaScripters Event Sep 17, 2016 · 2:00 PM: Scalable Javascript Design PatternsJavaScripters Event Sep 17, 2016 · 2:00 PM: Scalable Javascript Design Patterns
JavaScripters Event Sep 17, 2016 · 2:00 PM: Scalable Javascript Design Patterns
JavaScripters Community
 
Scalable JavaScript Design Patterns
Scalable JavaScript Design PatternsScalable JavaScript Design Patterns
Scalable JavaScript Design Patterns
Addy Osmani
 
Introduction to Design Patterns in Javascript
Introduction to Design Patterns in JavascriptIntroduction to Design Patterns in Javascript
Introduction to Design Patterns in Javascript
Santhosh Kumar Srinivasan
 
JavaScript design patterns introduction
JavaScript design patterns introductionJavaScript design patterns introduction
JavaScript design patterns introduction
D Balaji
 
Introduction to JavaScript design patterns
Introduction to JavaScript design patternsIntroduction to JavaScript design patterns
Introduction to JavaScript design patterns
Jeremy Duvall
 
Unleashing the Power of Modern Javascript Development
Unleashing the Power of Modern Javascript DevelopmentUnleashing the Power of Modern Javascript Development
Unleashing the Power of Modern Javascript Development
Tarandeep Singh
 
Future-proofing Your JavaScript Apps (Compact edition)
Future-proofing Your JavaScript Apps (Compact edition)Future-proofing Your JavaScript Apps (Compact edition)
Future-proofing Your JavaScript Apps (Compact edition)
Addy Osmani
 
Presenter deck icenium hol
Presenter deck   icenium holPresenter deck   icenium hol
Presenter deck icenium hol
Dhananjay Kumar
 
JavaScript Design Patterns
JavaScript Design PatternsJavaScript Design Patterns
JavaScript Design Patterns
Derek Brown
 
Ad

More from Amit Thakkar (10)

Packer
PackerPacker
Packer
Amit Thakkar
 
Packer
PackerPacker
Packer
Amit Thakkar
 
AWS Cloud Formation
AWS Cloud FormationAWS Cloud Formation
AWS Cloud Formation
Amit Thakkar
 
Introduction to node js
Introduction to node jsIntroduction to node js
Introduction to node js
Amit Thakkar
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejs
Amit Thakkar
 
A different thought angular js part-3
A different thought   angular js part-3A different thought   angular js part-3
A different thought angular js part-3
Amit Thakkar
 
A different thought angular js part-2
A different thought   angular js part-2A different thought   angular js part-2
A different thought angular js part-2
Amit Thakkar
 
A different thought AngularJS
A different thought AngularJSA different thought AngularJS
A different thought AngularJS
Amit Thakkar
 
Building user interface with react
Building user interface with reactBuilding user interface with react
Building user interface with react
Amit Thakkar
 
Get expertise with mongo db
Get expertise with mongo dbGet expertise with mongo db
Get expertise with mongo db
Amit Thakkar
 
AWS Cloud Formation
AWS Cloud FormationAWS Cloud Formation
AWS Cloud Formation
Amit Thakkar
 
Introduction to node js
Introduction to node jsIntroduction to node js
Introduction to node js
Amit Thakkar
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejs
Amit Thakkar
 
A different thought angular js part-3
A different thought   angular js part-3A different thought   angular js part-3
A different thought angular js part-3
Amit Thakkar
 
A different thought angular js part-2
A different thought   angular js part-2A different thought   angular js part-2
A different thought angular js part-2
Amit Thakkar
 
A different thought AngularJS
A different thought AngularJSA different thought AngularJS
A different thought AngularJS
Amit Thakkar
 
Building user interface with react
Building user interface with reactBuilding user interface with react
Building user interface with react
Amit Thakkar
 
Get expertise with mongo db
Get expertise with mongo dbGet expertise with mongo db
Get expertise with mongo db
Amit Thakkar
 

Recently uploaded (20)

Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 

Design pattern in an expressive language java script

  • 1. Design Pattern in an Expressive Language JavaScript Design Pattern
  • 2. Agenda ★ JavaScript Summary ★ What? Why? How? ★ Anti Pattern ★ Constructor Pattern ★ Module Pattern ★ Revealing Module Pattern ★ Facade Pattern ★ Promise Deferred Pattern ★ Decorator Pattern
  • 3. About Me Amit Thakkar Tech Blogger @ CodeChutney.in JavaScript Lover Working on MEAN Stack Twitter: @amit_thakkar01 LinkedIn: linkedin.com/in/amitthakkar01 Facebook: facebook.com/amit.thakkar01
  • 4. This session is targeted at professional developers wishing to improve their knowledge of design patterns and want to learn how to write beautiful, structured and organized code with JavaScript Programming Language. Target Audience
  • 5. JavaScript Summary 1. Everything is an Object 2. Loose Typing 3. Decent DOM API 4. Asynchronicity
  • 6. What? They are reusable solutions to commonly occurring problems in software design. Or we can say they are as templates for how we solve problems.
  • 7. They help us build upon the combined experience of many developers that came before us and ensure we structure our code in an optimized way, meeting the needs of problems we’re attempting to solve. Why?
  • 8. How? 1. They are proven solutions. 2. They are like component so can be easily reused. 3. They are common for all languages
  • 9. Anti Patterns 1. Polluting the global object. 2. Passing strings rather than function to either setTimeout or setInterval. 3. Modifying the Object class prototype. 4. Using JavaScript in an inline form as this is inflexible.
  • 10. Constructor Patterns JavaScript doesn't support the concept of classes but it does support special constructor functions that work with objects. By simply prefixing a call to a constructor function with the keyword "new", we can tell JavaScript we would like the function to behave like a constructor and instantiate a new object with the members defined by that function. Inside a constructor, the keyword this references the new object that's being created.
  • 11. You can checkout Demo form: https://github.com/AmitThakkar/JavaScriptDesignPattern
  • 12. Module Patterns The Module pattern was originally defined as a way to provide both private and public encapsulation for classes. Modules are an integral piece of any robust application's architecture.
  • 13. You can checkout Demo form: https://github.com/AmitThakkar/JavaScriptDesignPattern
  • 14. Exercise Time You can exercise form: https://github.com/AmitThakkar/JavaScriptDesignPattern
  • 15. Revealing Module Patterns In Module Pattern, we have to move function into object hash which we wished to make public. This pattern is improved version of Module pattern. In this pattern, we define all of our functions and variables in the private scope and return an anonymous object with pointers to the private functionality we wished to reveal as public.
  • 16. You can checkout Demo form: https://github.com/AmitThakkar/JavaScriptDesignPattern
  • 17. Facade Patterns This pattern provides a convenient higher-level interface to a larger body of code or may support methods with a wide range of behaviors, hiding its true underlying complexity.
  • 18. You can checkout Demo form: https://github.com/AmitThakkar/JavaScriptDesignPattern
  • 19. Example : 1 var addMyEvent = function( el,ev,fn ){ if( el.addEventListener ){ el.addEventListener( ev,fn, false ); }else if(el.attachEvent){ el.attachEvent( "on" + ev, fn ); } else{ el["on" + ev] = fn; } };
  • 20. Example : 2 bindReady: function() { if ( document.addEventListener ) { // Use the handy event callback document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); // A fallback to window.onload, that will always work window.addEventListener( "load", jQuery.ready, false ); // If IE event model is used } else if ( document.attachEvent ) { document.attachEvent( "onreadystatechange", DOMContentLoaded ); // A fallback to window.onload, that will always work window.attachEvent( "onload", jQuery.ready );
  • 21. Promise Deferred Patterns In the not too distant past the primary tool available to JavaScript programmers for handling asynchronous events was the callback.
  • 22. You can checkout Demo form: https://github.com/AmitThakkar/JavaScriptDesignPattern
  • 23. Exercise Time You can exercise form: https://github.com/AmitThakkar/JavaScriptDesignPattern
  • 24. Decorator/Wrapper Patterns It allows behavior to be added to an individual object, either statically or dynamically.
  • 25. You can checkout Demo form: https://github.com/AmitThakkar/JavaScriptDesignPattern

Editor's Notes

  • #9: 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.