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

Learn react-js
Learn react-jsLearn react-js
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
valuebound
 
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
500Tech
 
Reactjs notes.pptx for web development- tutorial and theory
Reactjs  notes.pptx for web development- tutorial and theoryReactjs  notes.pptx for web development- tutorial and theory
Reactjs notes.pptx for web development- tutorial and theory
jobinThomas54
 
Corso su ReactJS
Corso su ReactJSCorso su ReactJS
Corso su ReactJS
LinkMe Srl
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
StephieJohn
 
Rethinking React
Rethinking ReactRethinking React
Rethinking React
GlobalLogic Ukraine
 
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
Lama K Banna
 
Introduction to ReactJS and Redux
Introduction to ReactJS and ReduxIntroduction to ReactJS and Redux
Introduction to ReactJS and Redux
Boris 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
 
Lec7Handout.ppt
Lec7Handout.pptLec7Handout.ppt
Lec7Handout.ppt
MOMEKEMKUEFOUETDUREL
 
React Native in Production
React Native in ProductionReact Native in Production
React Native in Production
Seokjun 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 Clojurescript
John Stevenson
 
The productive developer guide to React
The productive developer guide to ReactThe productive developer guide to React
The productive developer guide to React
Maurice De Beijer [MVP]
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
floydophone
 
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
Devang Garach
 
Performance #3 layout&amp;animation
Performance #3  layout&amp;animationPerformance #3  layout&amp;animation
Performance #3 layout&amp;animation
Vitali Pekelis
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
Bethmi Gunasekara
 

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
 
Reactjs notes.pptx for web development- tutorial and theory
Reactjs  notes.pptx for web development- tutorial and theoryReactjs  notes.pptx for web development- tutorial and theory
Reactjs notes.pptx for web development- tutorial and theory
 
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
 

Recently uploaded

How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 

Recently uploaded (20)

How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 

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