SlideShare a Scribd company logo
1 of 63
Painless Migration From
Backbone to React/Redux
Jim Sullivan
Engineering Manager @ Conductor
jim@conductor.com
Painless Migration From
Backbone to React/Redux
Jim Sullivan
Engineering Manager @ Conductor
jim@conductor.com
Painless Migration From
Backbone to React/Redux
Jim Sullivan
Engineering Manager @ Conductor
jim@conductor.com
any Legacy Framework
Painless Migration From
Backbone to React/Redux
Jim Sullivan
Engineering Manager @ Conductor
jim@conductor.com
any Legacy Framework
4
5
6
JS @ CONDUCTOR: A BRIEF HISTORY
7
 Growing JavaScript codebase since 2009
JS @ CONDUCTOR: A BRIEF HISTORY
8
 Growing JavaScript codebase since 2009
 As of 2012
 Large, complex JavaScript application
JS @ CONDUCTOR: A BRIEF HISTORY
9
 Growing JavaScript codebase since 2009
 As of 2012
 Large, complex JavaScript application
 Homebrew/vanilla
JS @ CONDUCTOR: A BRIEF HISTORY
10
 Growing JavaScript codebase since 2009
 As of 2012
 Large, complex JavaScript application
 Homebrew/vanilla
 Time to choose a framework!
JS @ CONDUCTOR: A BRIEF HISTORY
11
 Growing JavaScript codebase since 2009
 As of 2012
 Large, complex JavaScript application
 Homebrew/vanilla
 Time to choose a framework!
JS @ CONDUCTOR: A BRIEF HISTORY
12
 Growing JavaScript codebase since 2009
 As of 2012
 Large, complex JavaScript application
 Homebrew/vanilla
 Time to choose a framework!
JS @ CONDUCTOR: A BRIEF HISTORY
13
 Growing JavaScript codebase since 2009
 As of 2012
 Large, complex JavaScript application
 Homebrew/vanilla
 Time to choose a framework!
 Now we had
 Object-oriented, non-global
JS @ CONDUCTOR: A BRIEF HISTORY
14
 Growing JavaScript codebase since 2009
 As of 2012
 Large, complex JavaScript application
 Homebrew/vanilla
 Time to choose a framework!
 Now we had
 Object-oriented, non-global
 Standard ways to do common actions
JS @ CONDUCTOR: A BRIEF HISTORY
15
 Growing JavaScript codebase since 2009
 As of 2012
 Large, complex JavaScript application
 Homebrew/vanilla
 Time to choose a framework!
 Now we had
 Object-oriented, non-global
 Standard ways to do common actions
 Architecture for layout and messaging
JS @ CONDUCTOR: A BRIEF HISTORY
16
 5 years!
JS @ CONDUCTOR: A BRIEF HISTORY
17
 5 years!
 As of 2017 – front end developers still feeling friction
JS @ CONDUCTOR: A BRIEF HISTORY
18
 5 years!
 As of 2017 – front end developers still feeling friction
 Hard to reason about data flow, messaging between components
 Hard to reason about where state lived
 Hard to reason about composing complex components and UIs
 etc. etc.
JS @ CONDUCTOR: A BRIEF HISTORY
19
 Flow of data and communication between components is more coherent
 State management is clearer
 Handling of state changes is more predictable
 Best practices and patterns around composing components and Uis
 etc. etc.
WHY REACT/REDUX?
20
THE PLAN FOR MIGRATING TO REACT/REDUX
21
Easy!
THE PLAN FOR MIGRATING TO REACT/REDUX
22
Easy!
All frontend engineers
THE PLAN FOR MIGRATING TO REACT/REDUX
23
Easy!
All frontend engineers
drop everything and stop building and
enhancing client-facing features
THE PLAN FOR MIGRATING TO REACT/REDUX
24
Easy!
All frontend engineers
drop everything and stop building and
enhancing client-facing features
until we’ve completely replaced hundreds
of thousands of lines of JS code! 👍 👍
THE PLAN FOR MIGRATING TO REACT/REDUX
25
Easy!
All frontend engineers
drop everything and stop building and
enhancing client-facing features
until we’ve completely replaced hundreds
of thousands of lines of JS code! 👍 👍
THE PLAN FOR MIGRATING TO REACT/REDUX
26
THE (REAL) PLAN FOR MIGRATING TO REACT/REDUX
27
THE (REAL) PLAN FOR MIGRATING TO REACT/REDUX
”…gradually create a new
system around the edges
of the old, letting it grow
slowly over several years
until the old system is
strangled.”
28
THE STRANGLER PATTERN
A B C
👤
29
THE STRANGLER PATTERN
A B C
👤
X
30
THE STRANGLER PATTERN
A1 B C
👤
X
31
THE STRANGLER PATTERN
A1 B1 C1
👤
X Y Z
32
 Where it gets tricky
THE STRANGLER PATTERN ON THE FRONT END
33
 Where it gets tricky
1. “As a user, I see a fancy new version of some common component”
 Rebuild it in React 👍
 New component needs to live on Backbone screens 😱
THE STRANGLER PATTERN ON THE FRONT END
34
 Where it gets tricky
1. “As a user, I see a fancy new version of some common component”
 Rebuild it in React 👍
 New component needs to live on Backbone screens 😱
2. “As a user, I see a fancy new/updated screen containing some old
common components”
 Build screen in React/Redux 👍
 Old backbone components live on that screen 😱
THE STRANGLER PATTERN ON THE FRONT END
35
 Straightforward application of Strangler Pattern in UI:
 Building new or updating old screens to 100% React/Redux
 Having 100% React/Redux screens live in the same application as 100%
Backbone/Marionette screens
THE STRANGLER PATTERN ON THE FRONT END
36
 Straightforward application of Strangler Pattern in UI:
 Building new or updating old screens to 100% React/Redux
 Having 100% React/Redux screens live in the same application as 100%
Backbone/Marionette screens
 Trickier application of Strangler Pattern in UI: hybrid screens
 What we needed:
1. Ability to wrap React Components in Backbone Views
2. Ability to wrap Backbone views in React Components and have them
interact with Redux
THE STRANGLER PATTERN ON THE FRONT END
37
WARNING
38
 We need a Backbone-style render method
 React Component’s render method returns React elements intended
for the Virtual DOM
 Backbone View’s render method directly modifies a DOM element
 We need it to be easy so people use it!
WRAPPING REACT COMPONENTS IN BACKBONE VIEWS
39
WRAPPING REACT COMPONENTS IN BACKBONE VIEWS
function createComponentBackboneWrapper(ComponentClass) {
const WrapperView = Backbone.View.extend({
// initialize(options)
// render()
// update(newProps)
});
return WrapperView;
};
40
WRAPPING REACT COMPONENTS IN BACKBONE VIEWS
initialize(options) {
WrapperView.__super__.initialize.call(this, options);
const getPropsFromOptions = (options) => pick(options, (value, key) =>
contains(Object.keys(ComponentClass.propTypes, key));
this._componentProps = Object.freeze(getPropsFromOptions(options));
},
41
WRAPPING REACT COMPONENTS IN BACKBONE VIEWS
initialize(options) {
WrapperView.__super__.initialize.call(this, options);
const getPropsFromOptions = (options) => pick(options, (value, key) =>
contains(Object.keys(ComponentClass.propTypes, key));
this._componentProps = Object.freeze(getPropsFromOptions(options));
},
render() {
ReactDOM.render(React.createElement(ComponentClass,
this._componentProps), this.el);
return this;
},
42
WRAPPING REACT COMPONENTS IN BACKBONE VIEWS
update(newComponentProps) {
this._componentProps = Object.freeze(Object.assign(
{},
this._componentProps,
getPropsFromOptions(newComponentProps, propTypeKeys)
));
return this.render();
}
43
import MyButton from = ‘./ReactButtonComponent’;
const WrapperView = createComponentBackboneWrapper(MyButton);
const view = new WrapperView({
text: 'Click me',
el: $('#the-button')
});
view.render();
view.update({ text: 'Don’t click me' });
WRAPPING REACT COMPONENTS IN BACKBONE VIEWS
44
Three things to consider about wrapped Backbone views:
1. They will render HTML directly to the DOM, which is not consistent
with React Component.render
2. They may be stateful, and therefore are not disposable, i.e. must not
be re-instantiated
3. They may need to affect shared state, i.e. dispatch Redux actions
WRAPPING BACKBONE VIEWS IN REACT/REDUX
45
WRAPPING BACKBONE VIEWS: RENDERING
46
WRAPPING BACKBONE VIEWS: RENDERING
47
WRAPPING BACKBONE VIEWS: RENDERING
48
class WrappedBackboneTextArea extends Component {
render() {
return ( <div ref={(ref) => { this._wrapperRef = ref; } } /> );
}
}
WRAPPING BACKBONE VIEWS: RENDERING
49
class WrappedBackboneTextArea extends Component {
render() {
return ( <div ref={(ref) => { this._wrapperRef = ref; } } /> );
}
componentDidMount() {
this.wrappedTextArea = new MyBackboneTextArea ({
el: this._wrapperRef
});
this.wrappedTextArea.render();
}
}
WRAPPING BACKBONE VIEWS: RENDERING
50
WRAPPING BACKBONE VIEWS: MAINTAINING STATE
51
class WrappedBackboneTextArea extends Component {
shouldComponentUpdate() {
return false;
}
WRAPPING BACKBONE VIEWS: MAINTAINING STATE
52
class WrappedBackboneTextArea extends Component {
shouldComponentUpdate() {
return false;
}
componentWillReceiveProps(nextProps) {
...
}
}
WRAPPING BACKBONE VIEWS: MAINTAINING STATE
53
class WrappedBackboneTextArea extends Component {
shouldComponentUpdate() {
return false;
}
componentWillReceiveProps(nextProps) {
this.wrappedTextArea.model.set(nextProps);
}
}
WRAPPING BACKBONE VIEWS: MAINTAINING STATE
54
WRAPPING BACKBONE VIEWS: AFFECTING SHARED STATE
55
class WrappedBackboneTextArea extends Component {
static propTypes = {
onChange: PropTypes.func.isRequired
};
}
WRAPPING BACKBONE VIEWS: AFFECTING SHARED STATE
56
class WrappedBackboneTextArea extends Component {
static propTypes = {
onChange: PropTypes.func.isRequired
};
componentDidMount() {
...
this.wrappedTextArea.model.on('change:text', () => {
this.props.onChange(this.wrappedTextArea.model.get(‘text’));
});
}
}
WRAPPING BACKBONE VIEWS: AFFECTING SHARED STATE
57
WHERE ARE WE NOW? WHAT’S NEXT?
58
 ~ 80% of front end development is happening in React/Redux right now
 That number is growing quickly
WHERE ARE WE NOW? WHAT’S NEXT?
59
 ~ 80% of front end development is happening in React/Redux right now
 That number is growing quickly
 How do we measure success? Shipping React/Redux code isn’t enough.
WHERE ARE WE NOW? WHAT’S NEXT?
60
 ~ 80% of front end development is happening in React/Redux right now
 That number is growing quickly
 How do we measure success? Shipping React/Redux code isn’t enough.
 Quality
WHERE ARE WE NOW? WHAT’S NEXT?
61
 ~ 80% of front end development is happening in React/Redux right now
 That number is growing quickly
 How do we measure success? Shipping React/Redux code isn’t enough.
 Quality
 Velocity
WHERE ARE WE NOW? WHAT’S NEXT?
62
 ~ 80% of front end development is happening in React/Redux right now
 That number is growing quickly
 How do we measure success? Shipping React/Redux code isn’t enough.
 Quality
 Velocity
 Anecdotally: most engineers using R/R are saying they are faster, more
confident about quality, less frustrated
WHERE ARE WE NOW? WHAT’S NEXT?
63
QUESTIONS?

More Related Content

Similar to Painless Migrations from Backbone to React/Redux

React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Previewvaluebound
 
ReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparisonReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparison500Tech
 
Corso su ReactJS
Corso su ReactJSCorso su ReactJS
Corso su ReactJSLinkMe Srl
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react jsStephieJohn
 
React gsg presentation with ryan jung &amp; elias malik
React   gsg presentation with ryan jung &amp; elias malikReact   gsg presentation with ryan jung &amp; elias malik
React gsg presentation with ryan jung &amp; elias malikLama K Banna
 
Introduction to ReactJS and Redux
Introduction to ReactJS and ReduxIntroduction to ReactJS and Redux
Introduction to ReactJS and ReduxBoris Dinkevich
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs[T]echdencias
 
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!Ryan Roemer
 
React Native in Production
React Native in ProductionReact Native in Production
React Native in ProductionSeokjun Kim
 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today Nitin Tyagi
 
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 ClojurescriptJohn Stevenson
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practicesfloydophone
 
Overview of React.JS - Internship Presentation - Week 5
Overview of React.JS - Internship Presentation - Week 5Overview of React.JS - Internship Presentation - Week 5
Overview of React.JS - Internship Presentation - Week 5Devang Garach
 
Performance #3 layout&amp;animation
Performance #3  layout&amp;animationPerformance #3  layout&amp;animation
Performance #3 layout&amp;animationVitali Pekelis
 

Similar to Painless Migrations from Backbone to React/Redux (20)

Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
 
ReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparisonReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparison
 
Corso su ReactJS
Corso su ReactJSCorso su ReactJS
Corso su ReactJS
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
 
Rethinking React
Rethinking ReactRethinking React
Rethinking React
 
React gsg presentation with ryan jung &amp; elias malik
React   gsg presentation with ryan jung &amp; elias malikReact   gsg presentation with ryan jung &amp; elias malik
React gsg presentation with ryan jung &amp; elias malik
 
Introduction to ReactJS and Redux
Introduction to ReactJS and ReduxIntroduction to ReactJS and Redux
Introduction to ReactJS and Redux
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs
 
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!
 
Lec7Handout.ppt
Lec7Handout.pptLec7Handout.ppt
Lec7Handout.ppt
 
React Native in Production
React Native in ProductionReact Native in Production
React Native in Production
 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today
 
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
 
The productive developer guide to React
The productive developer guide to ReactThe productive developer guide to React
The productive developer guide to React
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
 
Overview of React.JS - Internship Presentation - Week 5
Overview of React.JS - Internship Presentation - Week 5Overview of React.JS - Internship Presentation - Week 5
Overview of React.JS - Internship Presentation - Week 5
 
Performance #3 layout&amp;animation
Performance #3  layout&amp;animationPerformance #3  layout&amp;animation
Performance #3 layout&amp;animation
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
React workshop
React workshopReact workshop
React workshop
 

Recently uploaded

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Painless Migrations from Backbone to React/Redux

  • 1. Painless Migration From Backbone to React/Redux Jim Sullivan Engineering Manager @ Conductor jim@conductor.com Painless Migration From Backbone to React/Redux Jim Sullivan Engineering Manager @ Conductor jim@conductor.com
  • 2. Painless Migration From Backbone to React/Redux Jim Sullivan Engineering Manager @ Conductor jim@conductor.com any Legacy Framework
  • 3. Painless Migration From Backbone to React/Redux Jim Sullivan Engineering Manager @ Conductor jim@conductor.com any Legacy Framework
  • 4. 4
  • 5. 5
  • 6. 6 JS @ CONDUCTOR: A BRIEF HISTORY
  • 7. 7  Growing JavaScript codebase since 2009 JS @ CONDUCTOR: A BRIEF HISTORY
  • 8. 8  Growing JavaScript codebase since 2009  As of 2012  Large, complex JavaScript application JS @ CONDUCTOR: A BRIEF HISTORY
  • 9. 9  Growing JavaScript codebase since 2009  As of 2012  Large, complex JavaScript application  Homebrew/vanilla JS @ CONDUCTOR: A BRIEF HISTORY
  • 10. 10  Growing JavaScript codebase since 2009  As of 2012  Large, complex JavaScript application  Homebrew/vanilla  Time to choose a framework! JS @ CONDUCTOR: A BRIEF HISTORY
  • 11. 11  Growing JavaScript codebase since 2009  As of 2012  Large, complex JavaScript application  Homebrew/vanilla  Time to choose a framework! JS @ CONDUCTOR: A BRIEF HISTORY
  • 12. 12  Growing JavaScript codebase since 2009  As of 2012  Large, complex JavaScript application  Homebrew/vanilla  Time to choose a framework! JS @ CONDUCTOR: A BRIEF HISTORY
  • 13. 13  Growing JavaScript codebase since 2009  As of 2012  Large, complex JavaScript application  Homebrew/vanilla  Time to choose a framework!  Now we had  Object-oriented, non-global JS @ CONDUCTOR: A BRIEF HISTORY
  • 14. 14  Growing JavaScript codebase since 2009  As of 2012  Large, complex JavaScript application  Homebrew/vanilla  Time to choose a framework!  Now we had  Object-oriented, non-global  Standard ways to do common actions JS @ CONDUCTOR: A BRIEF HISTORY
  • 15. 15  Growing JavaScript codebase since 2009  As of 2012  Large, complex JavaScript application  Homebrew/vanilla  Time to choose a framework!  Now we had  Object-oriented, non-global  Standard ways to do common actions  Architecture for layout and messaging JS @ CONDUCTOR: A BRIEF HISTORY
  • 16. 16  5 years! JS @ CONDUCTOR: A BRIEF HISTORY
  • 17. 17  5 years!  As of 2017 – front end developers still feeling friction JS @ CONDUCTOR: A BRIEF HISTORY
  • 18. 18  5 years!  As of 2017 – front end developers still feeling friction  Hard to reason about data flow, messaging between components  Hard to reason about where state lived  Hard to reason about composing complex components and UIs  etc. etc. JS @ CONDUCTOR: A BRIEF HISTORY
  • 19. 19  Flow of data and communication between components is more coherent  State management is clearer  Handling of state changes is more predictable  Best practices and patterns around composing components and Uis  etc. etc. WHY REACT/REDUX?
  • 20. 20 THE PLAN FOR MIGRATING TO REACT/REDUX
  • 21. 21 Easy! THE PLAN FOR MIGRATING TO REACT/REDUX
  • 22. 22 Easy! All frontend engineers THE PLAN FOR MIGRATING TO REACT/REDUX
  • 23. 23 Easy! All frontend engineers drop everything and stop building and enhancing client-facing features THE PLAN FOR MIGRATING TO REACT/REDUX
  • 24. 24 Easy! All frontend engineers drop everything and stop building and enhancing client-facing features until we’ve completely replaced hundreds of thousands of lines of JS code! 👍 👍 THE PLAN FOR MIGRATING TO REACT/REDUX
  • 25. 25 Easy! All frontend engineers drop everything and stop building and enhancing client-facing features until we’ve completely replaced hundreds of thousands of lines of JS code! 👍 👍 THE PLAN FOR MIGRATING TO REACT/REDUX
  • 26. 26 THE (REAL) PLAN FOR MIGRATING TO REACT/REDUX
  • 27. 27 THE (REAL) PLAN FOR MIGRATING TO REACT/REDUX ”…gradually create a new system around the edges of the old, letting it grow slowly over several years until the old system is strangled.”
  • 31. 31 THE STRANGLER PATTERN A1 B1 C1 👤 X Y Z
  • 32. 32  Where it gets tricky THE STRANGLER PATTERN ON THE FRONT END
  • 33. 33  Where it gets tricky 1. “As a user, I see a fancy new version of some common component”  Rebuild it in React 👍  New component needs to live on Backbone screens 😱 THE STRANGLER PATTERN ON THE FRONT END
  • 34. 34  Where it gets tricky 1. “As a user, I see a fancy new version of some common component”  Rebuild it in React 👍  New component needs to live on Backbone screens 😱 2. “As a user, I see a fancy new/updated screen containing some old common components”  Build screen in React/Redux 👍  Old backbone components live on that screen 😱 THE STRANGLER PATTERN ON THE FRONT END
  • 35. 35  Straightforward application of Strangler Pattern in UI:  Building new or updating old screens to 100% React/Redux  Having 100% React/Redux screens live in the same application as 100% Backbone/Marionette screens THE STRANGLER PATTERN ON THE FRONT END
  • 36. 36  Straightforward application of Strangler Pattern in UI:  Building new or updating old screens to 100% React/Redux  Having 100% React/Redux screens live in the same application as 100% Backbone/Marionette screens  Trickier application of Strangler Pattern in UI: hybrid screens  What we needed: 1. Ability to wrap React Components in Backbone Views 2. Ability to wrap Backbone views in React Components and have them interact with Redux THE STRANGLER PATTERN ON THE FRONT END
  • 38. 38  We need a Backbone-style render method  React Component’s render method returns React elements intended for the Virtual DOM  Backbone View’s render method directly modifies a DOM element  We need it to be easy so people use it! WRAPPING REACT COMPONENTS IN BACKBONE VIEWS
  • 39. 39 WRAPPING REACT COMPONENTS IN BACKBONE VIEWS function createComponentBackboneWrapper(ComponentClass) { const WrapperView = Backbone.View.extend({ // initialize(options) // render() // update(newProps) }); return WrapperView; };
  • 40. 40 WRAPPING REACT COMPONENTS IN BACKBONE VIEWS initialize(options) { WrapperView.__super__.initialize.call(this, options); const getPropsFromOptions = (options) => pick(options, (value, key) => contains(Object.keys(ComponentClass.propTypes, key)); this._componentProps = Object.freeze(getPropsFromOptions(options)); },
  • 41. 41 WRAPPING REACT COMPONENTS IN BACKBONE VIEWS initialize(options) { WrapperView.__super__.initialize.call(this, options); const getPropsFromOptions = (options) => pick(options, (value, key) => contains(Object.keys(ComponentClass.propTypes, key)); this._componentProps = Object.freeze(getPropsFromOptions(options)); }, render() { ReactDOM.render(React.createElement(ComponentClass, this._componentProps), this.el); return this; },
  • 42. 42 WRAPPING REACT COMPONENTS IN BACKBONE VIEWS update(newComponentProps) { this._componentProps = Object.freeze(Object.assign( {}, this._componentProps, getPropsFromOptions(newComponentProps, propTypeKeys) )); return this.render(); }
  • 43. 43 import MyButton from = ‘./ReactButtonComponent’; const WrapperView = createComponentBackboneWrapper(MyButton); const view = new WrapperView({ text: 'Click me', el: $('#the-button') }); view.render(); view.update({ text: 'Don’t click me' }); WRAPPING REACT COMPONENTS IN BACKBONE VIEWS
  • 44. 44 Three things to consider about wrapped Backbone views: 1. They will render HTML directly to the DOM, which is not consistent with React Component.render 2. They may be stateful, and therefore are not disposable, i.e. must not be re-instantiated 3. They may need to affect shared state, i.e. dispatch Redux actions WRAPPING BACKBONE VIEWS IN REACT/REDUX
  • 48. 48 class WrappedBackboneTextArea extends Component { render() { return ( <div ref={(ref) => { this._wrapperRef = ref; } } /> ); } } WRAPPING BACKBONE VIEWS: RENDERING
  • 49. 49 class WrappedBackboneTextArea extends Component { render() { return ( <div ref={(ref) => { this._wrapperRef = ref; } } /> ); } componentDidMount() { this.wrappedTextArea = new MyBackboneTextArea ({ el: this._wrapperRef }); this.wrappedTextArea.render(); } } WRAPPING BACKBONE VIEWS: RENDERING
  • 50. 50 WRAPPING BACKBONE VIEWS: MAINTAINING STATE
  • 51. 51 class WrappedBackboneTextArea extends Component { shouldComponentUpdate() { return false; } WRAPPING BACKBONE VIEWS: MAINTAINING STATE
  • 52. 52 class WrappedBackboneTextArea extends Component { shouldComponentUpdate() { return false; } componentWillReceiveProps(nextProps) { ... } } WRAPPING BACKBONE VIEWS: MAINTAINING STATE
  • 53. 53 class WrappedBackboneTextArea extends Component { shouldComponentUpdate() { return false; } componentWillReceiveProps(nextProps) { this.wrappedTextArea.model.set(nextProps); } } WRAPPING BACKBONE VIEWS: MAINTAINING STATE
  • 54. 54 WRAPPING BACKBONE VIEWS: AFFECTING SHARED STATE
  • 55. 55 class WrappedBackboneTextArea extends Component { static propTypes = { onChange: PropTypes.func.isRequired }; } WRAPPING BACKBONE VIEWS: AFFECTING SHARED STATE
  • 56. 56 class WrappedBackboneTextArea extends Component { static propTypes = { onChange: PropTypes.func.isRequired }; componentDidMount() { ... this.wrappedTextArea.model.on('change:text', () => { this.props.onChange(this.wrappedTextArea.model.get(‘text’)); }); } } WRAPPING BACKBONE VIEWS: AFFECTING SHARED STATE
  • 57. 57 WHERE ARE WE NOW? WHAT’S NEXT?
  • 58. 58  ~ 80% of front end development is happening in React/Redux right now  That number is growing quickly WHERE ARE WE NOW? WHAT’S NEXT?
  • 59. 59  ~ 80% of front end development is happening in React/Redux right now  That number is growing quickly  How do we measure success? Shipping React/Redux code isn’t enough. WHERE ARE WE NOW? WHAT’S NEXT?
  • 60. 60  ~ 80% of front end development is happening in React/Redux right now  That number is growing quickly  How do we measure success? Shipping React/Redux code isn’t enough.  Quality WHERE ARE WE NOW? WHAT’S NEXT?
  • 61. 61  ~ 80% of front end development is happening in React/Redux right now  That number is growing quickly  How do we measure success? Shipping React/Redux code isn’t enough.  Quality  Velocity WHERE ARE WE NOW? WHAT’S NEXT?
  • 62. 62  ~ 80% of front end development is happening in React/Redux right now  That number is growing quickly  How do we measure success? Shipping React/Redux code isn’t enough.  Quality  Velocity  Anecdotally: most engineers using R/R are saying they are faster, more confident about quality, less frustrated WHERE ARE WE NOW? WHAT’S NEXT?

Editor's Notes

  1. Topic sounds focused
  2. While I’m at it
  3. All migrations are painful Legacy code is painful Maybe you’ve never felt that pain >
  4. Green field If you’ve been eng long enough >
  5. Some Green field Brownfield Unless you want to stay forever browner First a little about how we got to our BF
  6. Disorganized code Managing state globally Jquery manipulating dom inconsistent, hard to understand
  7. Conductor growing Business growing Application growing
  8. Data lived in models HTML lived in views and templates
  9. Making requests to APIs Rendering, re-rendering, removing elements in the DOM
  10. Continued to grow Doing something right!
  11. Examples very briefly
  12. Not backbone’s fault? But easy to fuck up.
  13. We knew where we Wanted to be…
  14. needed a practical plan
  15. What’s this?
  16. Often used to describe BE Can be applied to FE migration Brief explanation of SP on FE
  17. Example features Backbone Want to migrate
  18. Utopia! Using SP on on FE gets tricky
  19. Not just talking about diff screens sidebyside in app Components sbs in page
  20. Not just talking about diff screens sidebyside in app Components sbs in page
  21. Not just talking about diff screens sidebyside in app Components sbs in page
  22. To summarize
  23. Let’s dig in
  24. Last one: we want you to use react Tempting not to when just working on a small piece
  25. A little too big for one slide 😄
  26. Have not yet initialized react component
  27. Created react component using props from options ReactDOM.Render usually used for root of react app
  28. hack for emulating passing props No way to explicitly update props Backbone render destructive - consistent Freeze is used to make props immutable
  29. Go through Let’s talk about first one
  30. Overall theme of page: “Are you sure?”
  31. You might not know this if you’re new Overall theme of page: “Are you sure?”
  32. Callback will be called when component mounts Arg will be that DOM element
  33. We also call remove on unmount
  34. Now we have wrapped BB rendering 2nd thing – must not re-instantiate BB view Statefulness
  35. 2nd thing – must not re-instantiate BB view Statefulness
  36. Usually not this simple Ok third thing – redux
  37. Ok third thing – redux
  38. Ok third thing – redux
  39. Mention lack of bugs
  40. ADD: specifically less race conditions around events firing Consistent information across everything