SlideShare una empresa de Scribd logo
1 de 53
Descargar para leer sin conexión
FUNCTIONAL WEB 
DEVELOPMENT - AN 
INTRODUCTION TO React.js
HELLO, MY NAME IS Bertrand 
KARERANGABO. 
@BERTRANDK
I WORK AT RANGLE.IO
Moar functional! 
— Nick Van Weerdenburg
typeof NaN === 'number' //=> true
WHAT PROBLEM ARE WE 
TALKING ABOUT TODAY?
Most software today is very 
much like an Egyptian 
pyramid with millions of 
bricks piled on top of each 
other, with no structural 
integrity, but just done by 
brute force and thousands 
of slaves. 
— Alan Kay
THE PROBLEM HOW CAN WE BUILD LARGE APPLICATIONS 
WITH DATA THAT CHANGES OVER TIME?
▸ A (very) short history of web development 
▸ OOP in the wild 
▸ Functional design 
▸ React.js 
▸ Immutable (data stuctures) 
▸ The server (SEO & performance) 
▸ The end
1979 · MODEL-VIEW-CONTROLLER IS BORN 
It was fist articulated by Trygve Reenskaug, Adele Goldberg and others 
at Xeroc PARC. 
MVC was conceived as a general solution to the problem of users 
controlling a large and complex data set.
MVC AND IT'S LATER VARIANTS HAVE ALL 
INHERITED FROM THE INITIAL OOP-BASED 
IMPLEMENTATION.
1990 · THE FIRST WEB 
BROWSER 
It was invented by Tim Berners-Lee and was 
initially called WorldWideWeb. 
▸ It was written in Objective-C. 
▸ It introduced an Internet-based document 
system called HyperText Markup Language. 
▸ The layout engine was a subclass of 
NeXTSTEP's Text class. 
▸ The document is static – if data changes, you 
must refresh!
1995 · THE FIRST DOM 
The Level 0 DOM was created by Netscape for Netscape Navigator 2.0. 
The idea was to give web developers a means by which to allow users to 
interact with a site. 
Given that an HTML document can be represented as a tree, the DOM API 
allows for developers to interact and manipulate the tree's nodes.
1995 · THE FIRST 
JAVASCRIPT
▸ A (very) short history of web development 
▸ OOP in the wild 
▸ Functional design 
▸ React.js 
▸ Immutable (data stuctures) 
▸ The server (SEO & performance) 
▸ The end
A SHOPPING CART
A SHOPPING CART - OOP DATA
A SHOPPING CART - OOP DATA & METHODS
Local state that changes over time is 
the root of all evil.
A BASIC COMPUTER IN 1995 
Ram: 8MB 
HDD: 1GB 
CPU: 33MHz
LET'S NOT WRITE 
SOFTWARE LIKE 
IT'S 1995.
WE NEED A 
BETTER 
ABSTRACTION
▸ A (very) short history of web development 
▸ OOP in the wild 
▸ Functional design 
▸ React.js 
▸ Immutable (data stuctures) 
▸ The server (SEO & performance) 
▸ The end
A SHOPPING CART - FP DATA
A SHOPPING CART - FP DATA
A SOLUTION 
REACT.JS + IMMUTABLE-JS
▸ A (very) short history of web development 
▸ OOP in the wild 
▸ Functional design 
▸ React.js 
▸ Immutable (data stuctures) 
▸ The server (SEO & performance) 
▸ The end
REACT.JS A JAVASCRIPT LIBRARY FOR BUILDING 
COMPOSABLE USER INTERFACES
REACT.JS VIRTUAL DOM 
The full DOM API in JavaScript. 
When rendering, it uses a diff implementation for ultra-high 
performance. 
f(newDOM, oldDOM) = Δ
REACT.JS COMPONENT 
var App = React.createClass({ 
render: function() { 
return React.DOM.h1(null, 'Hello'); 
}; 
});
REACT.JS RENDER 
var App = React.createClass({ 
render: function() { 
return React.DOM.h1(null, 'Hello'); 
}; 
}); 
React.renderComponent(App(null), document.body);
REACT.JS PROPS 
var french = 'Allo'; 
var App = React.createClass({ 
render: function() { 
return React.DOM.h1(null, this.props.salutation ); 
}; 
}); 
React.renderComponent(App({ salutation: french }), document.body);
REACT.JS DOM PROPERTIES 
var french = 'Allo'; 
var App = React.createClass({ 
render: function() { 
return React.DOM.h1({ className: 'title' }, this.props.salutation ); 
}; 
}); 
React.renderComponent(App({ salutation: french }), document.body);
REACT.JS EVENTS 
var french = 'Allo'; 
function scream() { 
alert("I've been clicked!"); 
} 
var App = React.createClass({ 
render: function() { 
return React.DOM.h1({ className: 'title', 
onClick: this.props.clickHandler }, 
this.props.salutation ); 
}; 
}); 
React.renderComponent(App({ salutation: french, clickHandler: scream }), document.body);
REACT.JS STATE* 
var french = 'Allo'; 
var App = React.createClass({ 
getInitialState: function() { 
return { name: 'Unknown' }; 
}, 
componentDidMount: function() { 
$.ajax({ 
url: '/me', 
dataType: 'json', 
success: function(data) { 
this.setState({ name: data }); 
}.bind(this); 
}); 
}, 
render: function() { 
var fullSalutation = this.props.salutation + ', ' + this.state.name; 
return React.DOM.h1(null, fullSalutation); 
}; 
}); 
React.renderComponent(App({ salutation: french }), document.body);
REACT.JS COMPONENT SPECIFICATION 
- render 
- getInitialState 
- getDefaultProps 
- propTypes 
- mixins 
- statics 
- displayName
REACT.JS COMPONENT LIFECYCLE 
Mounting: 
- componentWillMount 
- componentDidMount 
Updating: 
- componentWillReceiveProps 
- shouldComponentUpdate 
- componentWillUpdate 
- componentDidUpdate 
Unmounting: 
- componentWillUnmount
REACT.JS SHOPPING CART
▸ A (very) short history of web development 
▸ OOP in the wild 
▸ Functional design 
▸ React.js 
▸ Immutable (data stuctures) 
▸ The server (SEO & performance) 
▸ The end
IMMUTABLE IMMUTABLE AND PERSISTENT DATA 
STRUCTURES + SUPPORTING APIS
IMMUTABLE MAPS 
var map1 = Immutable.Map({ a: 1, b: 2, c: 3 }); 
map2 = map.set('b', 20); // note the assignment 
map2.get('b'); // 20 
map1.get('b'); // 2
IMMUTABLE VECTOR 
var vect1 = Immutable.Vector(1, 2); 
var vect2 = vect1.push(3, 4, 5); 
var vect3 = vect2.unshift(0); 
var vect4 = vect1.concat(vect2, vect3); 
assert(vect1.length === 2); 
assert(vect2.length === 5); 
assert(vect3.length === 6); 
assert(vect4.length === 13); 
assert(vect4.get(0) === 1);
IMMUTABLE EQUALITY 
var map1 = Immutable.Map({a:1, b:1, c:1}); 
var map2 = Immutable.Map({a:1, b:1, c:1}); 
assert(map1 !== map2); 
assert(Immutable.is(map1, map2) === true);
IMMUTABLE INTEROP 
var deep = Immutable.Map({a:1, b:2, c:Immutable.Vector(3,4,5)}); 
deep.toObject() // { a: 1, b: 2, c: Vector [ 3, 4, 5 ] } 
deep.toArray() // [ 1, 2, Vector [ 3, 4, 5 ] ] 
deep.toJS() // { a: 1, b: 2, c: [ 3, 4, 5 ] } 
JSON.stringify(deep) // '{"a":1,"b":2,"c":[3,4,5]}'
IMMUTABLE CURSORS 
var appData = Immutable.fromJS({ a: { b: { c: 1 } } }); 
var userData = appData.cursor(['a', 'b', 'c'], function(newData) { 
appData = newData; 
}); 
// ... elsewhere ... 
userData.deref(); // 1 
userData = userData.update(function(x) { return x + 1 }); 
userData.deref(); // 2 
// ... back to data ... 
appData.getIn(['a', 'b', 'c']); // 2
IMMUTABLE SHOPPING CART
▸ A (very) short history of web development 
▸ OOP in the wild 
▸ Functional design 
▸ React.js 
▸ Immutable (data stuctures) 
▸ The server (SEO & performance) 
▸ The end
SERVER-SIDE RENDERING 
var url = require('url') 
function(req, res, next) { 
// get the application path/stage 
var path = url.parse(req.url).pathname; 
// get a React.js component 
var app = App({path: path}); 
// render component into string instead of DOM 
var markup = React.renderComponentToString(app); 
// return full html and let client-side takeover 
res.send(markup); 
}
▸ A (very) short history of web development 
▸ OOP in the wild 
▸ Functional design 
▸ React.js 
▸ Immutable (data stuctures) 
▸ The server (SEO & performance) 
▸ The end
WE NOW HAVE SOLID MODEL 
FOR DATA THAT CHANGES 
OVER TIME.
MIND THE PUNCHLINE 
It's not important that the chicken crossed the road or even how it did 
it. 
What's important is why it crossed the road.
Thank you!

Más contenido relacionado

La actualidad más candente

Mobile webapplication development
Mobile webapplication developmentMobile webapplication development
Mobile webapplication development
Ganesh Gembali
 
Alexander Dymo - RailsConf 2014 - Improve performance: Optimize Memory and Up...
Alexander Dymo - RailsConf 2014 - Improve performance: Optimize Memory and Up...Alexander Dymo - RailsConf 2014 - Improve performance: Optimize Memory and Up...
Alexander Dymo - RailsConf 2014 - Improve performance: Optimize Memory and Up...
Alexander Dymo
 

La actualidad más candente (18)

Devoxx uk 2014 High performance in-memory Java with open source
Devoxx uk 2014   High performance in-memory Java with open sourceDevoxx uk 2014   High performance in-memory Java with open source
Devoxx uk 2014 High performance in-memory Java with open source
 
Mobile webapplication development
Mobile webapplication developmentMobile webapplication development
Mobile webapplication development
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
Alexander Dymo - RailsConf 2014 - Improve performance: Optimize Memory and Up...
Alexander Dymo - RailsConf 2014 - Improve performance: Optimize Memory and Up...Alexander Dymo - RailsConf 2014 - Improve performance: Optimize Memory and Up...
Alexander Dymo - RailsConf 2014 - Improve performance: Optimize Memory and Up...
 
MLBlock
MLBlockMLBlock
MLBlock
 
GCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow IntroductionGCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow Introduction
 
Sprint 39 review
Sprint 39 reviewSprint 39 review
Sprint 39 review
 
PostgreSQL v9.4features
PostgreSQL v9.4featuresPostgreSQL v9.4features
PostgreSQL v9.4features
 
Full Stack Toronto - the 3R Stack
Full Stack Toronto - the 3R StackFull Stack Toronto - the 3R Stack
Full Stack Toronto - the 3R Stack
 
Monitoring at a SAAS Startup: Tradeoffs and Tools
Monitoring at a SAAS Startup: Tradeoffs and ToolsMonitoring at a SAAS Startup: Tradeoffs and Tools
Monitoring at a SAAS Startup: Tradeoffs and Tools
 
The hitchhiker's guide to the Webpack - Sara Vieira - Codemotion Amsterdam 2017
The hitchhiker's guide to the Webpack - Sara Vieira - Codemotion Amsterdam 2017The hitchhiker's guide to the Webpack - Sara Vieira - Codemotion Amsterdam 2017
The hitchhiker's guide to the Webpack - Sara Vieira - Codemotion Amsterdam 2017
 
JavaScript Task Runners - Gulp & Grunt
JavaScript Task Runners - Gulp & GruntJavaScript Task Runners - Gulp & Grunt
JavaScript Task Runners - Gulp & Grunt
 
Reusing your frontend JS on the server with V8/Rhino
Reusing your frontend JS on the server with V8/RhinoReusing your frontend JS on the server with V8/Rhino
Reusing your frontend JS on the server with V8/Rhino
 
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
 
Building multi lingual and empatic bots - Sander van den Hoven - Codemotion A...
Building multi lingual and empatic bots - Sander van den Hoven - Codemotion A...Building multi lingual and empatic bots - Sander van den Hoven - Codemotion A...
Building multi lingual and empatic bots - Sander van den Hoven - Codemotion A...
 
React for Beginners
React for BeginnersReact for Beginners
React for Beginners
 
用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化
 
Sprint 36 review
Sprint 36 reviewSprint 36 review
Sprint 36 review
 

Destacado

Components are the Future of the Web: It’s Going To Be Okay
Components are the Future of the Web: It’s Going To Be OkayComponents are the Future of the Web: It’s Going To Be Okay
Components are the Future of the Web: It’s Going To Be Okay
FITC
 
The Life of <p>
The Life of <p>The Life of <p>
The Life of <p>
FITC
 
Reinvent Your Creative Process with Collaborative Hackathons
Reinvent Your Creative Process with Collaborative HackathonsReinvent Your Creative Process with Collaborative Hackathons
Reinvent Your Creative Process with Collaborative Hackathons
FITC
 
The Shifting Nature of FED Role
The Shifting Nature of FED RoleThe Shifting Nature of FED Role
The Shifting Nature of FED Role
FITC
 

Destacado (20)

Making Mixed Reality Living Spaces
Making Mixed Reality Living SpacesMaking Mixed Reality Living Spaces
Making Mixed Reality Living Spaces
 
A Journey with React
A Journey with ReactA Journey with React
A Journey with React
 
From Box to Bots in Minutes
From Box to Bots in MinutesFrom Box to Bots in Minutes
From Box to Bots in Minutes
 
Building Tools for the Next Web
Building Tools for the Next WebBuilding Tools for the Next Web
Building Tools for the Next Web
 
21st Century Crystal Ball
21st Century Crystal Ball21st Century Crystal Ball
21st Century Crystal Ball
 
I HATE YOUR GAME with Bob Heubel
I HATE YOUR GAME with Bob HeubelI HATE YOUR GAME with Bob Heubel
I HATE YOUR GAME with Bob Heubel
 
Just Make Stuff!
Just Make Stuff!Just Make Stuff!
Just Make Stuff!
 
Getting to Know Grunt By Writing Your Own Plugin
Getting to Know Grunt By Writing Your Own PluginGetting to Know Grunt By Writing Your Own Plugin
Getting to Know Grunt By Writing Your Own Plugin
 
Here Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingHere Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript Debugging
 
The Browser Is Dead, Long Live The Web!
The Browser Is Dead, Long Live The Web!The Browser Is Dead, Long Live The Web!
The Browser Is Dead, Long Live The Web!
 
Components are the Future of the Web: It’s Going To Be Okay
Components are the Future of the Web: It’s Going To Be OkayComponents are the Future of the Web: It’s Going To Be Okay
Components are the Future of the Web: It’s Going To Be Okay
 
I Heard React Was Good
I Heard React Was GoodI Heard React Was Good
I Heard React Was Good
 
Managing Responsive Design Projects
Managing Responsive Design ProjectsManaging Responsive Design Projects
Managing Responsive Design Projects
 
Squishy pixels
Squishy pixelsSquishy pixels
Squishy pixels
 
How We Used To, How We Will
How We Used To, How We WillHow We Used To, How We Will
How We Used To, How We Will
 
The Life of <p>
The Life of <p>The Life of <p>
The Life of <p>
 
Reinvent Your Creative Process with Collaborative Hackathons
Reinvent Your Creative Process with Collaborative HackathonsReinvent Your Creative Process with Collaborative Hackathons
Reinvent Your Creative Process with Collaborative Hackathons
 
Your UX is not my UX
Your UX is not my UXYour UX is not my UX
Your UX is not my UX
 
My Type of Life
My Type of LifeMy Type of Life
My Type of Life
 
The Shifting Nature of FED Role
The Shifting Nature of FED RoleThe Shifting Nature of FED Role
The Shifting Nature of FED Role
 

Similar a Functional Web Development

JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Chartbeat
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
Wei Ru
 

Similar a Functional Web Development (20)

Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
 
The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
 
Play framework
Play frameworkPlay framework
Play framework
 
Clean Architecture @ Taxibeat
Clean Architecture @ TaxibeatClean Architecture @ Taxibeat
Clean Architecture @ Taxibeat
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
 
React october2017
React october2017React october2017
React october2017
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)
 
Dropwizard Introduction
Dropwizard IntroductionDropwizard Introduction
Dropwizard Introduction
 
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gears
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS Application
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
jsDay 2016 recap
jsDay 2016 recapjsDay 2016 recap
jsDay 2016 recap
 
Backbone.js with React Views - Server Rendering, Virtual DOM, and More!
Backbone.js with React Views - Server Rendering, Virtual DOM, and More!Backbone.js with React Views - Server Rendering, Virtual DOM, and More!
Backbone.js with React Views - Server Rendering, Virtual DOM, and More!
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
 
Incrementalism: An Industrial Strategy For Adopting Modern Automation
Incrementalism: An Industrial Strategy For Adopting Modern AutomationIncrementalism: An Industrial Strategy For Adopting Modern Automation
Incrementalism: An Industrial Strategy For Adopting Modern Automation
 
Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performance
 

Más de FITC

Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital Health
FITC
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
FITC
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight Websites
FITC
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is Terrifying
FITC
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future Human
FITC
 

Más de FITC (20)

Cut it up
Cut it upCut it up
Cut it up
 
Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital Health
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
 
Surviving Your Tech Stack
Surviving Your Tech StackSurviving Your Tech Stack
Surviving Your Tech Stack
 
How to Pitch Your First AR Project
How to Pitch Your First AR ProjectHow to Pitch Your First AR Project
How to Pitch Your First AR Project
 
Start by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerStart by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the Answer
 
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryCocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s Story
 
Everyday Innovation
Everyday InnovationEveryday Innovation
Everyday Innovation
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight Websites
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is Terrifying
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future Human
 
The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)
 
East of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameEast of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR Game
 
Creating a Proactive Healthcare System
Creating a Proactive Healthcare SystemCreating a Proactive Healthcare System
Creating a Proactive Healthcare System
 
World Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignWorld Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product Design
 
The Power of Now
The Power of NowThe Power of Now
The Power of Now
 
High Performance PWAs
High Performance PWAsHigh Performance PWAs
High Performance PWAs
 
Rise of the JAMstack
Rise of the JAMstackRise of the JAMstack
Rise of the JAMstack
 
From Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFrom Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self Discovery
 
Projects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForProjects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time For
 

Último

➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
nirzagarg
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
ydyuyu
 
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 

Último (20)

20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
 
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 

Functional Web Development

  • 1. FUNCTIONAL WEB DEVELOPMENT - AN INTRODUCTION TO React.js
  • 2. HELLO, MY NAME IS Bertrand KARERANGABO. @BERTRANDK
  • 3. I WORK AT RANGLE.IO
  • 4. Moar functional! — Nick Van Weerdenburg
  • 5. typeof NaN === 'number' //=> true
  • 6. WHAT PROBLEM ARE WE TALKING ABOUT TODAY?
  • 7. Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves. — Alan Kay
  • 8. THE PROBLEM HOW CAN WE BUILD LARGE APPLICATIONS WITH DATA THAT CHANGES OVER TIME?
  • 9.
  • 10. ▸ A (very) short history of web development ▸ OOP in the wild ▸ Functional design ▸ React.js ▸ Immutable (data stuctures) ▸ The server (SEO & performance) ▸ The end
  • 11. 1979 · MODEL-VIEW-CONTROLLER IS BORN It was fist articulated by Trygve Reenskaug, Adele Goldberg and others at Xeroc PARC. MVC was conceived as a general solution to the problem of users controlling a large and complex data set.
  • 12. MVC AND IT'S LATER VARIANTS HAVE ALL INHERITED FROM THE INITIAL OOP-BASED IMPLEMENTATION.
  • 13. 1990 · THE FIRST WEB BROWSER It was invented by Tim Berners-Lee and was initially called WorldWideWeb. ▸ It was written in Objective-C. ▸ It introduced an Internet-based document system called HyperText Markup Language. ▸ The layout engine was a subclass of NeXTSTEP's Text class. ▸ The document is static – if data changes, you must refresh!
  • 14. 1995 · THE FIRST DOM The Level 0 DOM was created by Netscape for Netscape Navigator 2.0. The idea was to give web developers a means by which to allow users to interact with a site. Given that an HTML document can be represented as a tree, the DOM API allows for developers to interact and manipulate the tree's nodes.
  • 15. 1995 · THE FIRST JAVASCRIPT
  • 16. ▸ A (very) short history of web development ▸ OOP in the wild ▸ Functional design ▸ React.js ▸ Immutable (data stuctures) ▸ The server (SEO & performance) ▸ The end
  • 18. A SHOPPING CART - OOP DATA
  • 19. A SHOPPING CART - OOP DATA & METHODS
  • 20. Local state that changes over time is the root of all evil.
  • 21. A BASIC COMPUTER IN 1995 Ram: 8MB HDD: 1GB CPU: 33MHz
  • 22. LET'S NOT WRITE SOFTWARE LIKE IT'S 1995.
  • 23. WE NEED A BETTER ABSTRACTION
  • 24. ▸ A (very) short history of web development ▸ OOP in the wild ▸ Functional design ▸ React.js ▸ Immutable (data stuctures) ▸ The server (SEO & performance) ▸ The end
  • 25. A SHOPPING CART - FP DATA
  • 26. A SHOPPING CART - FP DATA
  • 27. A SOLUTION REACT.JS + IMMUTABLE-JS
  • 28. ▸ A (very) short history of web development ▸ OOP in the wild ▸ Functional design ▸ React.js ▸ Immutable (data stuctures) ▸ The server (SEO & performance) ▸ The end
  • 29. REACT.JS A JAVASCRIPT LIBRARY FOR BUILDING COMPOSABLE USER INTERFACES
  • 30. REACT.JS VIRTUAL DOM The full DOM API in JavaScript. When rendering, it uses a diff implementation for ultra-high performance. f(newDOM, oldDOM) = Δ
  • 31. REACT.JS COMPONENT var App = React.createClass({ render: function() { return React.DOM.h1(null, 'Hello'); }; });
  • 32. REACT.JS RENDER var App = React.createClass({ render: function() { return React.DOM.h1(null, 'Hello'); }; }); React.renderComponent(App(null), document.body);
  • 33. REACT.JS PROPS var french = 'Allo'; var App = React.createClass({ render: function() { return React.DOM.h1(null, this.props.salutation ); }; }); React.renderComponent(App({ salutation: french }), document.body);
  • 34. REACT.JS DOM PROPERTIES var french = 'Allo'; var App = React.createClass({ render: function() { return React.DOM.h1({ className: 'title' }, this.props.salutation ); }; }); React.renderComponent(App({ salutation: french }), document.body);
  • 35. REACT.JS EVENTS var french = 'Allo'; function scream() { alert("I've been clicked!"); } var App = React.createClass({ render: function() { return React.DOM.h1({ className: 'title', onClick: this.props.clickHandler }, this.props.salutation ); }; }); React.renderComponent(App({ salutation: french, clickHandler: scream }), document.body);
  • 36. REACT.JS STATE* var french = 'Allo'; var App = React.createClass({ getInitialState: function() { return { name: 'Unknown' }; }, componentDidMount: function() { $.ajax({ url: '/me', dataType: 'json', success: function(data) { this.setState({ name: data }); }.bind(this); }); }, render: function() { var fullSalutation = this.props.salutation + ', ' + this.state.name; return React.DOM.h1(null, fullSalutation); }; }); React.renderComponent(App({ salutation: french }), document.body);
  • 37. REACT.JS COMPONENT SPECIFICATION - render - getInitialState - getDefaultProps - propTypes - mixins - statics - displayName
  • 38. REACT.JS COMPONENT LIFECYCLE Mounting: - componentWillMount - componentDidMount Updating: - componentWillReceiveProps - shouldComponentUpdate - componentWillUpdate - componentDidUpdate Unmounting: - componentWillUnmount
  • 40. ▸ A (very) short history of web development ▸ OOP in the wild ▸ Functional design ▸ React.js ▸ Immutable (data stuctures) ▸ The server (SEO & performance) ▸ The end
  • 41. IMMUTABLE IMMUTABLE AND PERSISTENT DATA STRUCTURES + SUPPORTING APIS
  • 42. IMMUTABLE MAPS var map1 = Immutable.Map({ a: 1, b: 2, c: 3 }); map2 = map.set('b', 20); // note the assignment map2.get('b'); // 20 map1.get('b'); // 2
  • 43. IMMUTABLE VECTOR var vect1 = Immutable.Vector(1, 2); var vect2 = vect1.push(3, 4, 5); var vect3 = vect2.unshift(0); var vect4 = vect1.concat(vect2, vect3); assert(vect1.length === 2); assert(vect2.length === 5); assert(vect3.length === 6); assert(vect4.length === 13); assert(vect4.get(0) === 1);
  • 44. IMMUTABLE EQUALITY var map1 = Immutable.Map({a:1, b:1, c:1}); var map2 = Immutable.Map({a:1, b:1, c:1}); assert(map1 !== map2); assert(Immutable.is(map1, map2) === true);
  • 45. IMMUTABLE INTEROP var deep = Immutable.Map({a:1, b:2, c:Immutable.Vector(3,4,5)}); deep.toObject() // { a: 1, b: 2, c: Vector [ 3, 4, 5 ] } deep.toArray() // [ 1, 2, Vector [ 3, 4, 5 ] ] deep.toJS() // { a: 1, b: 2, c: [ 3, 4, 5 ] } JSON.stringify(deep) // '{"a":1,"b":2,"c":[3,4,5]}'
  • 46. IMMUTABLE CURSORS var appData = Immutable.fromJS({ a: { b: { c: 1 } } }); var userData = appData.cursor(['a', 'b', 'c'], function(newData) { appData = newData; }); // ... elsewhere ... userData.deref(); // 1 userData = userData.update(function(x) { return x + 1 }); userData.deref(); // 2 // ... back to data ... appData.getIn(['a', 'b', 'c']); // 2
  • 48. ▸ A (very) short history of web development ▸ OOP in the wild ▸ Functional design ▸ React.js ▸ Immutable (data stuctures) ▸ The server (SEO & performance) ▸ The end
  • 49. SERVER-SIDE RENDERING var url = require('url') function(req, res, next) { // get the application path/stage var path = url.parse(req.url).pathname; // get a React.js component var app = App({path: path}); // render component into string instead of DOM var markup = React.renderComponentToString(app); // return full html and let client-side takeover res.send(markup); }
  • 50. ▸ A (very) short history of web development ▸ OOP in the wild ▸ Functional design ▸ React.js ▸ Immutable (data stuctures) ▸ The server (SEO & performance) ▸ The end
  • 51. WE NOW HAVE SOLID MODEL FOR DATA THAT CHANGES OVER TIME.
  • 52. MIND THE PUNCHLINE It's not important that the chicken crossed the road or even how it did it. What's important is why it crossed the road.