SlideShare a Scribd company logo
Who are these dudes?
suprememoocow
mydigitalself
Andrew Newdigate
Mike Bartlett
Gitter is where
developers come to talk
120 000 registered users
24 000 public communities
Active every minute of every day
502 releases in 1.5 years
Zawinksi’s Law
Every program attempts to expand until it can read mail.
Those programs which cannot so expand are replaced by ones which can.
Act 1
Performance
Global Average
4.5Mbps
Akamai
Two Great Tools
OSX Network Link Conditioner
Chrome DevTools Network Throttle
Scene 1
Mistake: Assuming jQuery is fast enough
Chuck Norris’ keyboard
Finding performance problems
Don’t optimise too early
Focus on CollectionViews, CompositeViews
Improving the performance 1000% on a view that gets rendered once in
the application isn’t going to make the slightest bit of difference.
The Chrome
DevTools
Timeline is
Awesome
Example of
using Timelines
$.tooltip is really slow
Solution: change the tooltip
behaviour to only initialise the
tooltip on the first mouseover event
fired on the element
1ms per tooltip to 0.005ms per
tooltip
Easy performance win: attachElContent
Override this method in your collection/composite child views
// Abbreviated version of the attachElContent MixIn we use on Gitter
attachElContent: function(html) {
if (typeof html === 'string') {
this.el.innerHTML = html;
return this;
}
this.$el.html(html);
return this;
}
.innerHTML vs $.html
Scene 2
Mistake: Not pre-rendering content
Pre-rendering is good practice
Page indexing / SEO advantages to doing it
Perceived speed of page load is much faster
Avoid multiple reflows as the application loads
Less jankiness
Pre-rendering is messy
At the moment, done through a series of hacks:
• Server-side handlebars helpers
• Client-side Marionette extensions
Would be awesome to move this out into a semi-sane, open-source
library (or build it into Marionette!)
Fully pre-rendered Partially pre-rendered
Isomorphic LayoutViews
In LayoutView’s before:show event
• If the region is empty, initialise ChildView as per normal:
• If the region already contains content, mount the ChildView on the
existing element: 



view.showChildView(regionName,
new ChildView({ el: existingElement, template: false, ... options ... }));
view.showChildView(regionName, new ChildView({ ... options ... }));
Isomorphic CollectionViews
childViewOptions: function (model) {
if (!model.id) return;
var el = this.$el.find('> [data-id="' + model.id + '"]')[0];
if (!el) return;
return {
el: el,
template: false
};
},
<ul>
<li data-id="1">One</li>
<li data-id="2">Two</li>
<li data-id="3">Three</li>
</ul>
collection.reset([
{ id: “1”, name: “One” },
{ id: “2”, name: “Two” },
{ id: “3”, name: “Three” }
]);
Scene 3
Mistake: Too much Jason
“640 people ought to be enough for any room”
Thanks!
People Roster Data
~300 characters
In a 5000 user room, that’s 1.4MB of JSON
Retina and non-retina avatar URLs
Unused fields, duplicate data, etc
{
"id": "5298e2d5ed5ab0b3bf04c980",
"username": "suprememoocow",
"displayName": "Andrew Newdigate",
"url": "/suprememoocow",
"avatarUrlSmall": "https://avatars1.githubuser
"avatarUrlMedium": "https://avatars1.githubuse
"gv": "3",
"v": 30
}
How we represent them now
77 characters
In a 5000 user room, that’s still 375KB.
Limit the list to the first 20 people
{
"id": "5298e2d5ed5ab0b3bf04c980",
"username": "suprememoocow",
"gv": "3",
"v": 30
}
Scene 4
Mistake: Using .on too much
.on is a code smell
Using jquery events
Backbone events
Also, beware of long running setTimeouts
this.ui.actionButton.on('click', function() { 

window.alert('Yo'); 

});
this.model.on('change', function() { 

window.alert('Yo'); 

});
Obvious solution
Use modelEvents, collectionEvents and events
modelEvents: {
'change': 'onChange'
},
events: {
'click @ui.badge': 'onBadgeClicked'
},
collectionEvents: {
'add reset sync reset': 'showHideHeader'
},
Use listenTo for listening to Backbone.Events
this.listenTo(model, 'change', function() { })
When you still need .on
Remember to cleanup after yourself
onClick: function() {
this.$someElement.on('mouseenter', ...);
this.longRunningTimer = setTimeout(function() {}, 60000);
},
onDestroy: function() {
this.$someElement.off();
clearTimeout(this.longRunningTimer);
},
DevTools Heap
Snapshots
Take periodic snapshots
and use the comparison
view to find new allocations
Act 2
Software design mistakes
Scene 1
Mistake: Coupling view components together
MV* 101
This is how we’re taught to
structure MV* applications
at school.
Sometimes it’s easier to ignore the advice
We need to tell another view to do
something.
We’re in a rush, so we’ll just wire the
dependency in and fix it later.
var MyView = Mn.ItemView.extend({
...
onActionClicked: function() {
this.options.anotherView.doSomething();
},
})
var myView = new MyView({ anotherView:
anotherView });
Pretty soon we’ve got a tightly coupled mess
This makes change hard
Just try to:
• Move a view within the view hierarchy
• Remove a view in a certain environment
(unauthenticated view, mobile, etc)
Let’s change things
around a bit…
Marionette solutions
Use a shared model and update the model
wreqr, or better yet, Backbone.Radio
Imaginary Radio Behaviour
var MyView = Mn.ItemView.extend({
behaviors: {
Radio: {
name: 'ui',
comply: {
'chat:focus': 'focusChat'
…
},
focusChat: function() {
// ....
}
});
var AnotherView = Mn.ItemView.extend({
behaviors: {
Radio: {
name: 'ui'
},
},
onActionClicked: function() {
this.radio.command('chat:focus');
}
});
*correct spelling
Scene 2
Mistake: Messing with another view’s DOM
Quick and dirty
A component needs to respond to an action and change another
component’s DOM…
Easiest solution: just use jquery
onClick: function() {
$('#action-button').hide();
}
c/c++ pointer arithmetic
In c/c++, it’s possible to use pointer arithmetic to directly modify the
contents of a location in memory.
I’m sure you will all agree: this is a VERY BAD IDEA!
bptr = (byte*) &data;
bptr = bptr + 5;
iptr = (int*) bptr;
(*iptr) = 0xcafebabe;
Now imagine…
Your DOM is a global memory shared by all the Javascript code running
in your app
Each view in your app manages a distinct piece of the global memory
Mutating another view’s DOM is a bit like using pointer arithmetic to
change it’s memory behind it’s back
Don’t do it!
But why?
Refactoring becomes a nightmare
You’re creating hidden connections between views in your application.
Scene 3
Mistake: Different module formats on the client and server
Then
Client: AMD modules with RequireJS
Tests: run in a phantomjs
Server: commonjs modules with nodejs
Tests run in nodejs with mocha
Now
Client: commonjs modules with webpack
Server: commonjs modules with nodejs
Shared code is kept in shared
Shared code can be tested quickly using the nodejs and mocha, without
having to start a phantomjs browser
require.ensure();
// In your backbone router....
markdown: function() {
require.ensure(['views/markdown/markdownView'], function(require) {
var MarkdownView = require('views/markdown/markdownView');
appView.dialogRegion.show(new MarkdownView({}));
});
},
Act 3
In closing
Code Debt
A lot of these problems as the result of technical debt. When we started
building the project we chose Backbone, and only later did we switch to
Marionette.
Initially, we treated Marionette as a neat extension of Backbone, for
things like CollectionViews etc so the transition was gradual and left a
lot of technical debt around.
Marionette 2 PR
From a small prototype to a large application
A lot of the pain we’ve experienced has been down to the fact that we
started off with a small application which has grown larger and larger.
Start as you mean to go on
Gitter marionette deck

More Related Content

What's hot

Building Large Scale Javascript Application
Building Large Scale Javascript ApplicationBuilding Large Scale Javascript Application
Building Large Scale Javascript Application
Anis Ahmad
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture
Jiby John
 
AngularJS for designers and developers
AngularJS for designers and developersAngularJS for designers and developers
AngularJS for designers and developers
Kai Koenig
 
Top 45 jQuery Interview Questions and Answers | Edureka
Top 45 jQuery Interview Questions and Answers | EdurekaTop 45 jQuery Interview Questions and Answers | Edureka
Top 45 jQuery Interview Questions and Answers | Edureka
Edureka!
 
Five class-based views everyone has written by now
Five class-based views everyone has written by nowFive class-based views everyone has written by now
Five class-based views everyone has written by now
James Aylett
 
AngularJs
AngularJsAngularJs
AngularJs
syam kumar kk
 
Android how to hellowidget
Android how to hellowidgetAndroid how to hellowidget
Android how to hellowidget
Mohammad Ali Raza Siddiqui
 
React - An Introduction
React - An IntroductionReact - An Introduction
React - An Introduction
Tyler Johnston
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of today
gerbille
 
Building Rich User Experiences Without JavaScript Spaghetti
Building Rich User Experiences Without JavaScript SpaghettiBuilding Rich User Experiences Without JavaScript Spaghetti
Building Rich User Experiences Without JavaScript Spaghetti
Jared Faris
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)
Gabor Varadi
 
Dom selecting & jQuery
Dom selecting & jQueryDom selecting & jQuery
Dom selecting & jQuery
Kim Hunmin
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
Boyan Mihaylov
 
5 angularjs features
5 angularjs features5 angularjs features
5 angularjs features
Alexey (Mr_Mig) Migutsky
 
Client Side MVC & Angular
Client Side MVC & AngularClient Side MVC & Angular
Client Side MVC & Angular
Alexe Bogdan
 
Reactive Type-safe WebComponents
Reactive Type-safe WebComponentsReactive Type-safe WebComponents
Reactive Type-safe WebComponents
Martin Hochel
 
JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"
GeeksLab Odessa
 
ILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterpriseILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterprise
René Winkelmeyer
 

What's hot (18)

Building Large Scale Javascript Application
Building Large Scale Javascript ApplicationBuilding Large Scale Javascript Application
Building Large Scale Javascript Application
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture
 
AngularJS for designers and developers
AngularJS for designers and developersAngularJS for designers and developers
AngularJS for designers and developers
 
Top 45 jQuery Interview Questions and Answers | Edureka
Top 45 jQuery Interview Questions and Answers | EdurekaTop 45 jQuery Interview Questions and Answers | Edureka
Top 45 jQuery Interview Questions and Answers | Edureka
 
Five class-based views everyone has written by now
Five class-based views everyone has written by nowFive class-based views everyone has written by now
Five class-based views everyone has written by now
 
AngularJs
AngularJsAngularJs
AngularJs
 
Android how to hellowidget
Android how to hellowidgetAndroid how to hellowidget
Android how to hellowidget
 
React - An Introduction
React - An IntroductionReact - An Introduction
React - An Introduction
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of today
 
Building Rich User Experiences Without JavaScript Spaghetti
Building Rich User Experiences Without JavaScript SpaghettiBuilding Rich User Experiences Without JavaScript Spaghetti
Building Rich User Experiences Without JavaScript Spaghetti
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)
 
Dom selecting & jQuery
Dom selecting & jQueryDom selecting & jQuery
Dom selecting & jQuery
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
 
5 angularjs features
5 angularjs features5 angularjs features
5 angularjs features
 
Client Side MVC & Angular
Client Side MVC & AngularClient Side MVC & Angular
Client Side MVC & Angular
 
Reactive Type-safe WebComponents
Reactive Type-safe WebComponentsReactive Type-safe WebComponents
Reactive Type-safe WebComponents
 
JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"
 
ILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterpriseILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterprise
 

Viewers also liked

Attachment
AttachmentAttachment
Attachment
whatmwwt
 
Before & After Walls Design
Before & After Walls DesignBefore & After Walls Design
Before & After Walls Design
Dalia Sadany Dezines
 
How to choose a contractor
How to choose a contractorHow to choose a contractor
How to choose a contractor
Dalia Sadany Dezines
 
Attachment final
Attachment finalAttachment final
Attachment final
whatmwwt
 
Desarrollo organisacional
Desarrollo organisacional Desarrollo organisacional
Desarrollo organisacional
Juan Vilela
 
Ada lovelace expocicion
Ada lovelace expocicionAda lovelace expocicion
Ada lovelace expocicion
Janina Sanchez
 
Teaching science through games
Teaching science through gamesTeaching science through games
Teaching science through games
gayukana
 

Viewers also liked (8)

English
EnglishEnglish
English
 
Attachment
AttachmentAttachment
Attachment
 
Before & After Walls Design
Before & After Walls DesignBefore & After Walls Design
Before & After Walls Design
 
How to choose a contractor
How to choose a contractorHow to choose a contractor
How to choose a contractor
 
Attachment final
Attachment finalAttachment final
Attachment final
 
Desarrollo organisacional
Desarrollo organisacional Desarrollo organisacional
Desarrollo organisacional
 
Ada lovelace expocicion
Ada lovelace expocicionAda lovelace expocicion
Ada lovelace expocicion
 
Teaching science through games
Teaching science through gamesTeaching science through games
Teaching science through games
 

Similar to Gitter marionette deck

jquery summit presentation for large scale javascript applications
jquery summit  presentation for large scale javascript applicationsjquery summit  presentation for large scale javascript applications
jquery summit presentation for large scale javascript applications
DivyanshGupta922023
 
Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with Redux
FITC
 
Developing large scale JavaScript applications
Developing large scale JavaScript applicationsDeveloping large scale JavaScript applications
Developing large scale JavaScript applications
Milan Korsos
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web apps
climboid
 
The State of Front-end At CrowdTwist
The State of Front-end At CrowdTwistThe State of Front-end At CrowdTwist
The State of Front-end At CrowdTwist
Mark Fayngersh
 
Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera
Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo KumperaAdvanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera
Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera
Xamarin
 
Fundaments of Knockout js
Fundaments of Knockout jsFundaments of Knockout js
Fundaments of Knockout js
Flavius-Radu Demian
 
Mobile optimization
Mobile optimizationMobile optimization
Mobile optimization
purplecabbage
 
Vanjs backbone-powerpoint
Vanjs backbone-powerpointVanjs backbone-powerpoint
Vanjs backbone-powerpoint
Michael Yagudaev
 
Developing maintainable Cordova applications
Developing maintainable Cordova applicationsDeveloping maintainable Cordova applications
Developing maintainable Cordova applications
Ivano Malavolta
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
Ravi Bhadauria
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
valuebound
 
Intro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScriptIntro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScript
jasonsich
 
Zend server 6 using zf2, 2013 webinar
Zend server 6 using zf2, 2013 webinarZend server 6 using zf2, 2013 webinar
Zend server 6 using zf2, 2013 webinar
Yonni Mendes
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
jbandi
 
Bringing the light to the client with KnockoutJS
Bringing the light to the client with KnockoutJSBringing the light to the client with KnockoutJS
Bringing the light to the client with KnockoutJS
Boyan Mihaylov
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
Jonas Bandi
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Barry Gervin
 
Building richwebapplicationsusingasp
Building richwebapplicationsusingaspBuilding richwebapplicationsusingasp
Building richwebapplicationsusingasp
Giovanni Javier Jimenez Cadena
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 

Similar to Gitter marionette deck (20)

jquery summit presentation for large scale javascript applications
jquery summit  presentation for large scale javascript applicationsjquery summit  presentation for large scale javascript applications
jquery summit presentation for large scale javascript applications
 
Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with Redux
 
Developing large scale JavaScript applications
Developing large scale JavaScript applicationsDeveloping large scale JavaScript applications
Developing large scale JavaScript applications
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web apps
 
The State of Front-end At CrowdTwist
The State of Front-end At CrowdTwistThe State of Front-end At CrowdTwist
The State of Front-end At CrowdTwist
 
Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera
Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo KumperaAdvanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera
Advanced Memory Management on iOS and Android - Mark Probst and Rodrigo Kumpera
 
Fundaments of Knockout js
Fundaments of Knockout jsFundaments of Knockout js
Fundaments of Knockout js
 
Mobile optimization
Mobile optimizationMobile optimization
Mobile optimization
 
Vanjs backbone-powerpoint
Vanjs backbone-powerpointVanjs backbone-powerpoint
Vanjs backbone-powerpoint
 
Developing maintainable Cordova applications
Developing maintainable Cordova applicationsDeveloping maintainable Cordova applications
Developing maintainable Cordova applications
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
 
Intro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScriptIntro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScript
 
Zend server 6 using zf2, 2013 webinar
Zend server 6 using zf2, 2013 webinarZend server 6 using zf2, 2013 webinar
Zend server 6 using zf2, 2013 webinar
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
 
Bringing the light to the client with KnockoutJS
Bringing the light to the client with KnockoutJSBringing the light to the client with KnockoutJS
Bringing the light to the client with KnockoutJS
 
From User Action to Framework Reaction
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
 
Building richwebapplicationsusingasp
Building richwebapplicationsusingaspBuilding richwebapplicationsusingasp
Building richwebapplicationsusingasp
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 

Recently uploaded

Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
christinelarrosa
 
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's TipsGetting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
ScyllaDB
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
DanBrown980551
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
MySQL InnoDB Storage Engine: Deep Dive - MydbopsMySQL InnoDB Storage Engine: Deep Dive - Mydbops
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
Mydbops
 
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdfLee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
leebarnesutopia
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
ScyllaDB
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
HarpalGohil4
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptxAI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
Sunil Jagani
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
LizaNolte
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 

Recently uploaded (20)

Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
 
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's TipsGetting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
MySQL InnoDB Storage Engine: Deep Dive - MydbopsMySQL InnoDB Storage Engine: Deep Dive - Mydbops
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
 
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdfLee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptxAI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 

Gitter marionette deck

  • 1.
  • 2. Who are these dudes? suprememoocow mydigitalself Andrew Newdigate Mike Bartlett
  • 3. Gitter is where developers come to talk 120 000 registered users 24 000 public communities Active every minute of every day 502 releases in 1.5 years
  • 4. Zawinksi’s Law Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.
  • 7. Two Great Tools OSX Network Link Conditioner Chrome DevTools Network Throttle
  • 8. Scene 1 Mistake: Assuming jQuery is fast enough
  • 10. Finding performance problems Don’t optimise too early Focus on CollectionViews, CompositeViews Improving the performance 1000% on a view that gets rendered once in the application isn’t going to make the slightest bit of difference.
  • 12. Example of using Timelines $.tooltip is really slow Solution: change the tooltip behaviour to only initialise the tooltip on the first mouseover event fired on the element 1ms per tooltip to 0.005ms per tooltip
  • 13. Easy performance win: attachElContent Override this method in your collection/composite child views // Abbreviated version of the attachElContent MixIn we use on Gitter attachElContent: function(html) { if (typeof html === 'string') { this.el.innerHTML = html; return this; } this.$el.html(html); return this; }
  • 15. Scene 2 Mistake: Not pre-rendering content
  • 16. Pre-rendering is good practice Page indexing / SEO advantages to doing it Perceived speed of page load is much faster Avoid multiple reflows as the application loads Less jankiness
  • 17. Pre-rendering is messy At the moment, done through a series of hacks: • Server-side handlebars helpers • Client-side Marionette extensions Would be awesome to move this out into a semi-sane, open-source library (or build it into Marionette!)
  • 19. Isomorphic LayoutViews In LayoutView’s before:show event • If the region is empty, initialise ChildView as per normal: • If the region already contains content, mount the ChildView on the existing element: 
 
 view.showChildView(regionName, new ChildView({ el: existingElement, template: false, ... options ... })); view.showChildView(regionName, new ChildView({ ... options ... }));
  • 20. Isomorphic CollectionViews childViewOptions: function (model) { if (!model.id) return; var el = this.$el.find('> [data-id="' + model.id + '"]')[0]; if (!el) return; return { el: el, template: false }; }, <ul> <li data-id="1">One</li> <li data-id="2">Two</li> <li data-id="3">Three</li> </ul> collection.reset([ { id: “1”, name: “One” }, { id: “2”, name: “Two” }, { id: “3”, name: “Three” } ]);
  • 21. Scene 3 Mistake: Too much Jason
  • 22. “640 people ought to be enough for any room”
  • 24. People Roster Data ~300 characters In a 5000 user room, that’s 1.4MB of JSON Retina and non-retina avatar URLs Unused fields, duplicate data, etc { "id": "5298e2d5ed5ab0b3bf04c980", "username": "suprememoocow", "displayName": "Andrew Newdigate", "url": "/suprememoocow", "avatarUrlSmall": "https://avatars1.githubuser "avatarUrlMedium": "https://avatars1.githubuse "gv": "3", "v": 30 }
  • 25. How we represent them now 77 characters In a 5000 user room, that’s still 375KB. Limit the list to the first 20 people { "id": "5298e2d5ed5ab0b3bf04c980", "username": "suprememoocow", "gv": "3", "v": 30 }
  • 26. Scene 4 Mistake: Using .on too much
  • 27. .on is a code smell Using jquery events Backbone events Also, beware of long running setTimeouts this.ui.actionButton.on('click', function() { 
 window.alert('Yo'); 
 }); this.model.on('change', function() { 
 window.alert('Yo'); 
 });
  • 28. Obvious solution Use modelEvents, collectionEvents and events modelEvents: { 'change': 'onChange' }, events: { 'click @ui.badge': 'onBadgeClicked' }, collectionEvents: { 'add reset sync reset': 'showHideHeader' }, Use listenTo for listening to Backbone.Events this.listenTo(model, 'change', function() { })
  • 29. When you still need .on Remember to cleanup after yourself onClick: function() { this.$someElement.on('mouseenter', ...); this.longRunningTimer = setTimeout(function() {}, 60000); }, onDestroy: function() { this.$someElement.off(); clearTimeout(this.longRunningTimer); },
  • 30. DevTools Heap Snapshots Take periodic snapshots and use the comparison view to find new allocations
  • 32. Scene 1 Mistake: Coupling view components together
  • 33. MV* 101 This is how we’re taught to structure MV* applications at school.
  • 34. Sometimes it’s easier to ignore the advice We need to tell another view to do something. We’re in a rush, so we’ll just wire the dependency in and fix it later. var MyView = Mn.ItemView.extend({ ... onActionClicked: function() { this.options.anotherView.doSomething(); }, }) var myView = new MyView({ anotherView: anotherView });
  • 35. Pretty soon we’ve got a tightly coupled mess
  • 36. This makes change hard Just try to: • Move a view within the view hierarchy • Remove a view in a certain environment (unauthenticated view, mobile, etc) Let’s change things around a bit…
  • 37. Marionette solutions Use a shared model and update the model wreqr, or better yet, Backbone.Radio
  • 38. Imaginary Radio Behaviour var MyView = Mn.ItemView.extend({ behaviors: { Radio: { name: 'ui', comply: { 'chat:focus': 'focusChat' … }, focusChat: function() { // .... } }); var AnotherView = Mn.ItemView.extend({ behaviors: { Radio: { name: 'ui' }, }, onActionClicked: function() { this.radio.command('chat:focus'); } }); *correct spelling
  • 39. Scene 2 Mistake: Messing with another view’s DOM
  • 40. Quick and dirty A component needs to respond to an action and change another component’s DOM… Easiest solution: just use jquery onClick: function() { $('#action-button').hide(); }
  • 41. c/c++ pointer arithmetic In c/c++, it’s possible to use pointer arithmetic to directly modify the contents of a location in memory. I’m sure you will all agree: this is a VERY BAD IDEA! bptr = (byte*) &data; bptr = bptr + 5; iptr = (int*) bptr; (*iptr) = 0xcafebabe;
  • 42. Now imagine… Your DOM is a global memory shared by all the Javascript code running in your app Each view in your app manages a distinct piece of the global memory Mutating another view’s DOM is a bit like using pointer arithmetic to change it’s memory behind it’s back Don’t do it!
  • 43. But why? Refactoring becomes a nightmare You’re creating hidden connections between views in your application.
  • 44. Scene 3 Mistake: Different module formats on the client and server
  • 45. Then Client: AMD modules with RequireJS Tests: run in a phantomjs Server: commonjs modules with nodejs Tests run in nodejs with mocha
  • 46. Now Client: commonjs modules with webpack Server: commonjs modules with nodejs Shared code is kept in shared Shared code can be tested quickly using the nodejs and mocha, without having to start a phantomjs browser
  • 47. require.ensure(); // In your backbone router.... markdown: function() { require.ensure(['views/markdown/markdownView'], function(require) { var MarkdownView = require('views/markdown/markdownView'); appView.dialogRegion.show(new MarkdownView({})); }); },
  • 49. Code Debt A lot of these problems as the result of technical debt. When we started building the project we chose Backbone, and only later did we switch to Marionette. Initially, we treated Marionette as a neat extension of Backbone, for things like CollectionViews etc so the transition was gradual and left a lot of technical debt around. Marionette 2 PR
  • 50. From a small prototype to a large application A lot of the pain we’ve experienced has been down to the fact that we started off with a small application which has grown larger and larger. Start as you mean to go on