SlideShare a Scribd company logo
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

Recently uploaded (20)

IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 

Modern JavaScript Development @ DotNetToscana