SlideShare a Scribd company logo
Backbone to React. What it says about awesome UI Code.
16
200
Unit tests written per month
usability testing
added
keyboard controls
7
10
Views or components written per month
apples and pears comparison
http://bit.ly/1MvDN1h
1. Simplicity
2. Predictability
3. Composability
1Simplicity
data = _.extend({
isHighlighted: this.isHighlighted
},
this.user.toJSON(),
this.account.toJSON()
});
html = Mustache.render(Template, data);
this.$el.html(template);
return this.$el;
var classes = "user-wrapper"
if (this.state.isHighlighted) {
var classes += " is-highlighted"
}
return (
<div className={classes}>
<strong>{this.props.userName}</strong>
<img src={this.props.avatar} />
<span>account: {this.props.accountName}
</div>
);
Reducing short term
memory usage
simplicity
this.render = _.debounce( this.render )
React Runtime
render
input input input input input
Remove, don’t conquer
complexity
simplicity
emails = this.user.get(‘emails')
data = {
hasEmail: emails.length > 0
}
html = Mustache.render(Template, data)
simplicity complexity
1. Reduce short term memory usage
2. Remove, don’t conquer complexity
simplicity:
2Predictability
propTypes: {
firstName: React.PropTypes.string.isRequired,
emails: React.PropTypes.arrayOf([
React.PropTypes.string
]),
permission: React.PropTypes.oneOf([
"admin",
"limited",
"normal"
])
}
PropTypes: http://bit.ly/1FDQmuq& Model: http://bit.ly/1PsG9mf
incorrect type:
duplicate keys:
mutating props incorrectly:
defending against 

future mistakes
predictability
if (!Array.isArray(instances)) {
type = typeof instances;
msg = "listenToEvents expects array,not:";
console.warn(msg + " " + type);
}
“
our powers to visualize
processes evolving in time are
relatively poorly developed
Edsger W. Dijkstra
http://bit.ly/1fzrqcm
Async Data Fetching
User Interaction
Flow breaking code
Data
1. WillRecieveProps
2. ShouldUpdate
3. WillUpdate
4. Render
5. DidUpdate
component 1:
component 2:
Data
1. WillRecieveProps
2. ShouldUpdate
3. WillUpdate
4. Render
5. DidUpdate
Data
lifecycle methodscomponent 1:
lifecycle methods
lifecycle methods
lifecycle methods
lifecycle methods
component 2:
component 3:
component 4:
component 5:
http://bit.ly/1R69Xsi
initialize: function(model) {
this.model = model
this.listenTo(
this.model,
"change:name",
this.changeName
)
}
changeName: function() {
name = this.model.get('name')
this.$el.find('.name').html(name)
}
make the model 

of time simpler
predictability
initialize: function(model) {
this.model = model
this.listenTo(
this.model,
"change:name",
this.changeName
)
}
changeName: function() {
name = this.model.get('name')
this.$el.find('.name').html(name)
}
1. lifecycle methods
1. render?
2. manual dom updates?
3. data binding?
4. updating children?
slow enough to be unpredictable
fast enough to be predictable
Standardise the 

effects of time
predictability
1. Defend against future mistakes
2. Make the model of time simpler
3. Standardise the effects of time
predictability:
3composability
“
"A highly composable system
provides ... components that can
be selected and assembled in
various combinations to satisfy
specific user requirements"
blog.kissmetrics.com/loading-time/
dropdown controls
1
2
3 4 5 6
render: function() {
this.$el.html(Mustache.render(Template));
$wrapper = this.$el.find(‘.childView');
this.childView.setElement($wrapper);
this.childView.render();
return this.$el;
}
Backbone: Add a child view?
Make component 

interfaces performant
composability
Backbone: Extend a class?
SelectableRow = Row.extend({
events: function() {
oldEvents = Row.prototype.events;
newEvents = {'click': 'select'};
return _.extend(oldEvents, newEvents});
}
template: require('selectable-row.html'),
getViewData: function() {
return model.toJSON();
}
});
toggleOpen: function() {
this.setState({open: !this.state.open})
},
render: function() {
return (
<DropdownControls
toggleOpenState={this.toggleOpen}
open={this.state.open}
>
<div>shown when state.open</div>
</DropdownControls>
)
}
React: Add a child component
Make component 

interfaces explicit
composability
14
25
Generic components vs views
2.2
4.8
Generic component/view usage
1. Performant component interfaces
2. Explicit component interfaces
composability:
4Summary
What is good code?
1. Simple
2. Predictable
3. Composable
Good code
1. Fewer regressions
2. Less serious regressions
3. More code re-use
4. Shipping faster

5. Better usability & UX
8
22 DEC 09:23AM
Simple and beautiful
Further reading
Functional programming
Composabilty
State
Complect
Implicit vs Explicit
@byrichardpowell
follow me for musings on
React.js, UI Development & Product Design

More Related Content

PPTX
Introduction to React JS
PPTX
BackboneJS + ReactJS
PPTX
React & Redux JS
PPTX
Intro to React
ODP
Running ms sql stored procedures in mule
PDF
Backbone
PPTX
Backbone.js and friends
PPTX
Planbox Backbone MVC
Introduction to React JS
BackboneJS + ReactJS
React & Redux JS
Intro to React
Running ms sql stored procedures in mule
Backbone
Backbone.js and friends
Planbox Backbone MVC

What's hot (20)

PDF
Backbone js
PDF
React JS & Functional Programming Principles
PPTX
Introduction to React JS for beginners
ODP
Javascript frameworks: Backbone.js
PPTX
Introduction to react js
PPT
BackboneJs
PPTX
The Benefits of Using React JS for Web Development!
PDF
Backbone.js with React Views - Server Rendering, Virtual DOM, and More!
PPTX
[Final] ReactJS presentation
PPTX
Vývojařská Plzeň - React
PDF
ODP
BackboneJS and friends
PDF
Javascript ui for rest services
PPTX
20180518 QNAP Seminar - Introduction to React Native
PDF
Spring mvc
PDF
Backbone js in action
PDF
Understanding backbonejs
PPT
Backbone js-slides
ODP
Box connector Mule ESB Integration
PPTX
Its time to React.js
Backbone js
React JS & Functional Programming Principles
Introduction to React JS for beginners
Javascript frameworks: Backbone.js
Introduction to react js
BackboneJs
The Benefits of Using React JS for Web Development!
Backbone.js with React Views - Server Rendering, Virtual DOM, and More!
[Final] ReactJS presentation
Vývojařská Plzeň - React
BackboneJS and friends
Javascript ui for rest services
20180518 QNAP Seminar - Introduction to React Native
Spring mvc
Backbone js in action
Understanding backbonejs
Backbone js-slides
Box connector Mule ESB Integration
Its time to React.js
Ad

Similar to Backbone to React. What it says about awesome UI Code. (20)

PDF
React for Dummies
PDF
Structuring React.js Components
PDF
4Developers 2018: Structuring React components (Bartłomiej Witczak)
PPTX
React responsively, render responsibly - react meetup
PDF
React.js or why DOM finally makes sense
PPTX
React Responsively, Render Responsibly
PDF
2- Components.pdf
PDF
React Best Practices All Developers Should Follow in 2024.pdf
PDF
Strategies for Mitigating Complexity in React Based Redux Applicaitons
PDF
React 101
PPTX
React Hooks Best Practices in 2022.pptx
PDF
React & The Art of Managing Complexity
PDF
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
PDF
Workshop 19: ReactJS Introduction
PPTX
React performance tips, Тельман Агабабов
PPTX
Learn react.js with me!
PDF
React lecture
PDF
Integrating React.js with PHP projects
PDF
Advanced React Component Patterns - ReactNext 2018
PDF
React.js: Beyond the Browser
React for Dummies
Structuring React.js Components
4Developers 2018: Structuring React components (Bartłomiej Witczak)
React responsively, render responsibly - react meetup
React.js or why DOM finally makes sense
React Responsively, Render Responsibly
2- Components.pdf
React Best Practices All Developers Should Follow in 2024.pdf
Strategies for Mitigating Complexity in React Based Redux Applicaitons
React 101
React Hooks Best Practices in 2022.pptx
React & The Art of Managing Complexity
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
Workshop 19: ReactJS Introduction
React performance tips, Тельман Агабабов
Learn react.js with me!
React lecture
Integrating React.js with PHP projects
Advanced React Component Patterns - ReactNext 2018
React.js: Beyond the Browser
Ad

More from Richard Powell (10)

PDF
Designing user on-boarding
PDF
Data Visualisation with D3 & Rickshaw - Berlin Expert Days
PDF
Time-Series Monitoring Graphs with D3 & Rickshaw
PDF
Angular js, Yeomon & Grunt
PDF
D3 Rickshaw and Backbone in 50 minutes
PDF
Real-time collaborative drawing
PDF
Front end-performance
PDF
Angular.js, Yeomon & Grunt
KEY
Draw stuff at @jsnortheast
PPT
HTML5 Canvas @SuperMondays, Newcastle
Designing user on-boarding
Data Visualisation with D3 & Rickshaw - Berlin Expert Days
Time-Series Monitoring Graphs with D3 & Rickshaw
Angular js, Yeomon & Grunt
D3 Rickshaw and Backbone in 50 minutes
Real-time collaborative drawing
Front end-performance
Angular.js, Yeomon & Grunt
Draw stuff at @jsnortheast
HTML5 Canvas @SuperMondays, Newcastle

Recently uploaded (20)

PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Transform Your Business with a Software ERP System
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Digital Strategies for Manufacturing Companies
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
System and Network Administraation Chapter 3
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
ai tools demonstartion for schools and inter college
PDF
System and Network Administration Chapter 2
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Transform Your Business with a Software ERP System
Understanding Forklifts - TECH EHS Solution
Odoo Companies in India – Driving Business Transformation.pdf
Digital Strategies for Manufacturing Companies
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Reimagine Home Health with the Power of Agentic AI​
Designing Intelligence for the Shop Floor.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
System and Network Administraation Chapter 3
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Design an Analysis of Algorithms II-SECS-1021-03
ai tools demonstartion for schools and inter college
System and Network Administration Chapter 2

Backbone to React. What it says about awesome UI Code.