SlideShare a Scribd company logo
1 of 76
Modern
JavaScript
Development
Matteo Baglini
Software Developer, Freelance
@matteobaglini
matteo.baglini@gmail.com www.dotnettoscana.o
#jsfull
Thanks to our sponsor
Why JavaScript?How it all could have happened
The Birth of JavaScript
“The World's Most Misunderstood
Programming Language”
by Douglas Crockford
The Ancestors of JavaScript
Functions
(Lamba)
Lexical Scope
Loosely
Typed
Prototypal
Inheritance
Dynamic
Objects
Syntax
Some
convention
Name (Part)
Did you mean ECMAScript?
1996 – First public release
1999 – Becomes standard ECMA-262 as
ECMAScript 3
2009 – Major update ECMAScript 5
2011 – Last review ECMAScript 5.1 (ISO/IEC
16262:2011)
WIP* – Next version ECMAScript 6
“JavaScript is the only language
people feel like they don't need to
learn to use it”
by Douglas Crockford
Comes Web 2.0 & UX
“Hidden under a hugesteaming
pile of goodintentions and
blunders is
anelegant, expressiveprogrammin
g language. A language of many
contrasts.”
by Douglas Crockford
JavaScript Popularity
Back to BasicsJavaScript Building Block
Functions
Functions are first-class objects
Can be created at runtime
Can be stored in variables
Can be passed as parameters to functions
Can be returned by functions
Can be expressed as anonymous literals
Functions
Functions
Fundamental modular
unit
Encloses a set of
statements
Code Reuse
Information Hiding
Object Composition
Scope
No block-level
Lexical Scoping
Function (everywhere)
Global
Scope Chain
Hoisting
Declaration is moved to
the top of the scope
Also for function
declaration
Closure
Inner function get
access to variables and
parameter of parent
function
Variables, not values
Objects
JavaScript is
fundamentally about
objects
Arrays are objects
Functions are objects
Objects are objects
So what are objects?
Objects are collections
of name-value pairs
(properties)
Objects
Prototype
twitter
account: ...
prototype: -
name
first: ...
last: ...
prototype: -
Object
prototype: -
Linkage feature that
allows one object to
inherit the properties of
another
Context (this)
„This‟ represent the
context object
Determined by the
invocation pattern
Method invocation
Function invocation
Constructor invocation
Apply invocation
Context (this)
Object WayObject Oriented Programming and JavaScript
Object Creation
JavaScript provides
several different ways to
create an object
Object Literal
When we need only
one object of some
kind
Reduce a large
number of parameters
Collect settings
Object Creation
JavaScript provides
several different ways to
create an object
Constructor Function
When we need many
independent instance
of some object
Add constructor
logic
Reduce memory
allocation
Object Creation
JavaScript provides
several different ways to
create an object
ECMAScript 5
Creating an object
without going through
its constructor
Better object‟s
properties specification
Information Hiding
JavaScript does not
offer accessibility levels
(public, private, etc.) on
members
This does not mean
that JavaScript objects
can‟t have private
members
Information Hiding
The array will be
created each time the
function is invoked
Information Hiding
We can use functions
and closure to make
modules.
A module is a function
or object that
presents an interface
but that hides its
state and
implementation.
Also known as:
Module Pattern
Inheritance
(Pseudoclassical)Objects produced by
constructur functions
The prototype object
is the place where
inherited traits are to
be deposited
Create an object
whose prototype is
Function‟s prototype
and initialize it
executing Function
Pseudoclassical To The Max
Build a special class
object that
encapsulate repetitive
code
Use class object to
define other class
Instantiate new object
from class
Pseudoclassical To The Max
“Favor object composition over
class inheritance”
by Erich Gamma (GoF)
Inheritance (Prototypal)
JavaScript natual way
Class-free
Objects inherit from
objects (Delegation)
Customizing the new
one (Differential
Inheritance)
Officially a part of the
language
(ECMAScript 5)
Inheritance (Copying)
The easiest way
Objects inherit from
objects
(Shallow/Deep Copy)
Inheritance (Mixins)
Simulate multi-
inheritance
Objects inherit from
many objects
(Shallow/Deep Copy)
Functional WayFunctional Programming and JavaScript
Inheritance (Functional)
Also known as Power
Constructors
Define maker function
composed by four
steps
Creates a new
object
Defines private
members
Augments that new
object
Returns that new
object
Callback
Functions can make it
easier to deal with
discontinuous events
Typically used to
make an
asynchronous
requests
Combining with
closure it become an
great way to hide the
complexity
Callback
Take care to use "this"
in the callback
Be careful when
callback is a method
of an object
Iterator
Internal (passive)
iterator controlled by
the aggregate object
Take a callback as
parameter
Apply callback for
each item
Compact, hide
complex traverse logic
Iterator
Curry
Is a function
transformation
process (Haskell
Curry)
Produce a new
function by combining
a function and an
argument
When invoked, returns
the result of calling
that original
function, passing it all
of the arguments
Memoization
Functions can
remember the results
of previous operations
Use a simple cache
with combination of
objects and arrays
Speed up execution
ToolboxJavaScript Must Have Tools
Static Code Analysis
Programs
by Douglas Crockford
Static Code Analysis
Programs
Playground
Browser Inspector
Pack It!Organize the code base
Namespace Pattern
Create a single global
variable for your
application
Assign namespace
object to local variable
Act as “import”
directive
Namespace Pattern
Remove boring
definition code
Use a namespace
builder utility method
Module Pattern
Modules are an
integral piece, it
provides a way of
wrapping methods
and variables
Protecting pieces from
leaking into the global
scope
Clean solution for
shielding logic
Module Pattern
But is not enough, we need
more…
Asynchronous Module
Definition Pattern (AMD)
A format for writing
modular JavaScript in
the browser
Separate module
definition (define) and
dependencies loading
(require)
All can be
asynchronously
loaded
RequireJS Setup/Startup
Add require.js to the
scripts directory
Add custom
JavaScript application
start file to the scripts
directory
RequireJS Module Definition
How to encapsulate a
piece of code into a
useful unit
How to register its
capability/export a
value for the module
RequireJS Resolve
DependencyHow to refer to other
units of code
Test Early Test
OftenJavaScript Testing Strategy
Why is testing important?
Automated testing is very
important with dynamic
languages, but it is even more so
with JavaScript
Because JavaScript live into
browser…
…and browsers, with different
DOM API and different language
interpreters, make JavaScript
schizophrenic!
Unit Testing frameworks
QUnit Step 1 - Tests
QUnit Step 2 – Run/Result
JsTestDriver
Headless Testing
Karma way (ex Testacular)
Keep It Simple
Let‟s StudyJavaScript Books
Books
Books
Tutto il materiale di questa sessione su
Grazie!
#jsfull
http://www.dotnettoscana.org/javascript-full-immersion.aspx

More Related Content

What's hot

Object oriented javascript
Object oriented javascriptObject oriented javascript
Object oriented javascript
Garrison Locke
 

What's hot (20)

Object oriented javascript
Object oriented javascriptObject oriented javascript
Object oriented javascript
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
Spring Boot Microservices vs Akka Actor Cluster
Spring Boot Microservices vs Akka Actor Cluster Spring Boot Microservices vs Akka Actor Cluster
Spring Boot Microservices vs Akka Actor Cluster
 
Code Generation idioms with Xtend
Code Generation idioms with XtendCode Generation idioms with Xtend
Code Generation idioms with Xtend
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6
 
javerosmx-2015-marzo-groovy-java8-comparison
javerosmx-2015-marzo-groovy-java8-comparisonjaverosmx-2015-marzo-groovy-java8-comparison
javerosmx-2015-marzo-groovy-java8-comparison
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
 
OMP GSE
OMP GSEOMP GSE
OMP GSE
 
Why Reactive Architecture Will Take Over The World (and why we should be wary...
Why Reactive Architecture Will Take Over The World (and why we should be wary...Why Reactive Architecture Will Take Over The World (and why we should be wary...
Why Reactive Architecture Will Take Over The World (and why we should be wary...
 
Turbo charging v8 engine
Turbo charging v8 engineTurbo charging v8 engine
Turbo charging v8 engine
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
 
Node.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniquesNode.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniques
 
Node.js an Exectutive View
Node.js an Exectutive ViewNode.js an Exectutive View
Node.js an Exectutive View
 
Ratpack JVM_MX Meetup February 2016
Ratpack JVM_MX Meetup February 2016Ratpack JVM_MX Meetup February 2016
Ratpack JVM_MX Meetup February 2016
 
AWS for the Java Developer
AWS for the Java DeveloperAWS for the Java Developer
AWS for the Java Developer
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threads
 
Full-Stack, Message-oriented Programming w/ Akka.NET Actors
Full-Stack, Message-oriented Programming w/ Akka.NET ActorsFull-Stack, Message-oriented Programming w/ Akka.NET Actors
Full-Stack, Message-oriented Programming w/ Akka.NET Actors
 
Scala's evolving ecosystem- Introduction to Scala.js
Scala's evolving ecosystem- Introduction to Scala.jsScala's evolving ecosystem- Introduction to Scala.js
Scala's evolving ecosystem- Introduction to Scala.js
 
CPP13 - Object Orientation
CPP13 - Object OrientationCPP13 - Object Orientation
CPP13 - Object Orientation
 
The Actor Model - Towards Better Concurrency
The Actor Model - Towards Better ConcurrencyThe Actor Model - Towards Better Concurrency
The Actor Model - Towards Better Concurrency
 

Similar to Modern JavaScript Development @ DotNetToscana

Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02
Sopheak Sem
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
intelliyole
 

Similar to Modern JavaScript Development @ DotNetToscana (20)

Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java Language
 
Java Basics
Java BasicsJava Basics
Java Basics
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Play framework
Play frameworkPlay framework
Play framework
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-Frameworks
 
All of javascript
All of javascriptAll of javascript
All of javascript
 
JSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph PicklJSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph Pickl
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
Java scriptforjavadev part2a
Java scriptforjavadev part2aJava scriptforjavadev part2a
Java scriptforjavadev part2a
 
Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02
 
Fewd week4 slides
Fewd week4 slidesFewd week4 slides
Fewd week4 slides
 
jQuery with javascript training by Technnovation Labs
jQuery with javascript training by Technnovation LabsjQuery with javascript training by Technnovation Labs
jQuery with javascript training by Technnovation Labs
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
 
jQuery (intermediate)
jQuery (intermediate)jQuery (intermediate)
jQuery (intermediate)
 
A Taste of Clojure
A Taste of ClojureA Taste of Clojure
A Taste of Clojure
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6
 

More from Matteo Baglini

Legacy Coderetreat Bologna @ CodersTUG
Legacy Coderetreat Bologna @ CodersTUGLegacy Coderetreat Bologna @ CodersTUG
Legacy Coderetreat Bologna @ CodersTUG
Matteo Baglini
 
Approval Tests @ MiniIAD
Approval Tests @ MiniIADApproval Tests @ MiniIAD
Approval Tests @ MiniIAD
Matteo Baglini
 
Approval Tests @ CodersTUG
Approval Tests @ CodersTUGApproval Tests @ CodersTUG
Approval Tests @ CodersTUG
Matteo Baglini
 
Coderetreat @ CodersTUG
Coderetreat @ CodersTUGCoderetreat @ CodersTUG
Coderetreat @ CodersTUG
Matteo Baglini
 
The NoSQL movement @ DotNetToscana
The NoSQL movement @ DotNetToscanaThe NoSQL movement @ DotNetToscana
The NoSQL movement @ DotNetToscana
Matteo Baglini
 
Key-value databases in practice Redis @ DotNetToscana
Key-value databases in practice Redis @ DotNetToscanaKey-value databases in practice Redis @ DotNetToscana
Key-value databases in practice Redis @ DotNetToscana
Matteo Baglini
 

More from Matteo Baglini (11)

Writing Good Tests
Writing Good TestsWriting Good Tests
Writing Good Tests
 
Legacy Coderetreat Bologna @ CodersTUG
Legacy Coderetreat Bologna @ CodersTUGLegacy Coderetreat Bologna @ CodersTUG
Legacy Coderetreat Bologna @ CodersTUG
 
Approval Tests @ MiniIAD
Approval Tests @ MiniIADApproval Tests @ MiniIAD
Approval Tests @ MiniIAD
 
VS13 - Approval Tests: cosa, come, quando, perché? @ CDays
VS13 - Approval Tests: cosa, come, quando, perché? @ CDaysVS13 - Approval Tests: cosa, come, quando, perché? @ CDays
VS13 - Approval Tests: cosa, come, quando, perché? @ CDays
 
Approval Tests @ CodersTUG
Approval Tests @ CodersTUGApproval Tests @ CodersTUG
Approval Tests @ CodersTUG
 
Coderetreat @ CodersTUG
Coderetreat @ CodersTUGCoderetreat @ CodersTUG
Coderetreat @ CodersTUG
 
RESTFul Web API Services @ DotNetToscana
RESTFul Web API Services @ DotNetToscanaRESTFul Web API Services @ DotNetToscana
RESTFul Web API Services @ DotNetToscana
 
Async: scalabilità e responsiveness senza pari! @ CDays
Async: scalabilità e responsiveness senza pari! @ CDaysAsync: scalabilità e responsiveness senza pari! @ CDays
Async: scalabilità e responsiveness senza pari! @ CDays
 
The NoSQL movement @ DotNetToscana
The NoSQL movement @ DotNetToscanaThe NoSQL movement @ DotNetToscana
The NoSQL movement @ DotNetToscana
 
Key-value databases in practice Redis @ DotNetToscana
Key-value databases in practice Redis @ DotNetToscanaKey-value databases in practice Redis @ DotNetToscana
Key-value databases in practice Redis @ DotNetToscana
 
Asynchronous Programming Lab @ DotNetToscana
Asynchronous Programming Lab @ DotNetToscanaAsynchronous Programming Lab @ DotNetToscana
Asynchronous Programming Lab @ DotNetToscana
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Modern JavaScript Development @ DotNetToscana