SlideShare uma empresa Scribd logo
1 de 121
Baixar para ler offline
Transforming Front-end
Disaster Code™ Into a
Maintainable Masterpiece



@dangribbin
Hi, I’m Dan Gribbin
Software Engineer

brand networks

Web Development Teacher
rochester brainery
front end
js + css + html
design is critical to the
development process
.psd
design (a plan)
best available solution
| constraints
get requirements → write code → ship?
get requirements → write code → ship?
no.
plan system→ then write code
yep
disaster!
alpine
alpine

*internal name - not actual thing name
initial launch
- tight deadlines

- limited front-end resources
- good
- fast
- cheap

(pick two)
our plan lacked detail it
needed for the
future of the front-end
Technical Debt
poor engineering complicates
future work
software entropy
complexity will increase unless
an effort is made against it
we set our front end
up for failure
alpine launch → SDLC
2 week sprints


requirements → code →release
sprint : function() {
technicalDebt++;
},
performance
page load times
15 seconds
:(
poor engineering →
poor user experience
effects on our page load
- render-blocking scripts
- loading all resources on all pages
- lots of code, no minification

maintainability
Time and ease of…
- fixing a bug

- developing a new feature
impact?
↑ feature work dev time
↓ velocity
costs of an unmaintainable codebase to
you and your stakeholders
- time
- money
- frustration
influences on maintainability

JS
- globals

- intermixed functionality
SASS/CSS
- long, overly specific selectors
- confusing naming conventions
- Styles not logically separated

- Hitting IE9 selector limit
morale
entropic products affect the
teams that work on them
our software problems don’t
just belong to one person
your disaster is your team’s
disaster too.
disasters affect morale
(relationships), motivation,
and productivity
initial fixes
initial fixes
… mostly unsuccessful
:/
we needed a do-over
1UP
design!
neptune
much of our JavaScript wasn’t
terrible, just terribly organized
reorganization was top priority
separation, actually
MVC
Some MVC frameworks
ember, backbone, angular, knockout, dojo, YUI, CanJS, Maria, Polymer, React, cujo,
Montage, Ext, Sammy, Stapes, Epitome, soma, DUEL, Kendo UI, PureMVC, Olives,
Plastron, Dijon, rAppid.js, Deft, Aria, Exoskeleton, Atma, Ractive, ComponentJS
MVC frameworks
ember, backbone, angular, knockout, dojo, YUI, CanJS, Maria, Polymer, React, cujo,
Montage, Ext, Sammy, Stapes, Epitome, soma, DUEL, Kendo UI, PureMVC, Olives,
Plastron, Dijon, rAppid.js, Deft, Aria, Exoskeleton, Atma, Ractive, ComponentJS

was one of these right for us?
constraints
time + experience
AMD + RequireJS
define([’controllers/article-controller.js’],
function(ArticleController) {
ArticleController.init();
}
);
neptune’s front end stack
results
cut page load time by 80%
cut JS per-page by 70%
cut CSS per-page by 75%
-huge maintainability gains
-framework for future work
-testable code
where did we suck?
estimation.
seriously. ouch.
awesome team-building
experience
Things you can do right
now to clean up your
front end
Cleaning up means…
-optimizing for performance
-promoting maintainability
-ensuring reliability
optimize for performance
developer tools are your
best friends
using an image sprite?
you should be!
!

one request → all your icons
no <script>’s in your <head>
<head>
<title>Bad Ideas, Inc.</title>
<script src=“main.js”></script>
</head>
Instead…
…
<script src=“main.js”></script>
</body>
get some help optimizing
use a build tool
In the beginning, was

make
then, this guy stuck
his nose in
a challenger
appears?
which one should
you use?
whichever
one makes
you happy.
minimize and defer
resource loading
!
track down unused CSS
grunt-uncss
gulp-uncss
minify & combine
grunt-contrib-concat
grunt-contrib-uglify
!

gulp-uglify
gulp-concat
optimize images
grunt-contrib-imagemin
gulp-imagemin
!

or, use an app like ImageOptim
for manual operations
cache jQuery selections in your code
var galleryItems = $(‘.gallery-item’)

http://training.bocoup.com/screencasts/the-importance-ofcaching-jquery-selections/
promoting maintainability
a hallmark of a maintainable
codebase is organization
short term fixes
Check your styles
using less/sass?

be careful of the nesting trap.
instead of
!

li {
display: block;
}
!

li img {
width: 50px;
}
you can write
!

li {
display:block;
!

img {
width: 50px;
}
}
which is awesome! but be careful.
the following Disaster SASS™
is real code pulled from alpine



viewer discretion is advised
body.single {
.outer-wrapper {
#content{
#content_column{

ul {
li{
a{
img {
width: 50px !important;
}
}
}
}
}
}
}
}
which compiles to…
body.single .outer-wrapper #content #content_column ul li a img
{
width: 50px !important;
}
to override that, we’d need a selector
with a higher specificity and importance
see how this might get
out of hand quickly?
what if all your styles were so
messy? ours were.
how about this instead?
.gallery img {
width: 50px;
}

readable, reusable, maintainable
also, don’t use !important
if you need !important, you
have bigger problems to solve
Collaborate on a
standards document
helpful for getting the entire team
thinking about quality and consistency
involvement increases buy in
collaboration can be an effective
and positive teamwork experience
long term goals
organization through separation
(and avoiding their opposites)
modularize
JavaScript - AMD / MVC

CSS - SASS/LESS
modular code will help you
create extensible features
enforce separation of:
-style
-presentation
-behavior
use class names for on-the-fly
style adjustments
.addClass(‘error’)
instead of
.css(‘border’, ‘red’)
✓ reusable
✓ consistent
✓ maintainable

o/
keeping JavaScript out of HTML means only
having to look in one filetype
el.on(‘click’, doThing)

instead of
onclick=“doThing()”
navigating stakeholder relations
clear, understandable communication
how is what you’re saying relevant to business goals?
the quicker solution will often
lead to more cost down the road
negotiation
great client relationships
are possible!
remember
this is effort against
complexity
making effort against complexity benefits:

- you

- future you
- your team
- your stakeholders
make future-you
love past-you
the perfect
!

tool/framework/library
!

does not exist
plan & design software
for the situation at hand
thanks!
slides here: @dangribbin

Mais conteúdo relacionado

Mais procurados

Sizzle jQCon San Francisco 2012
Sizzle jQCon San Francisco 2012Sizzle jQCon San Francisco 2012
Sizzle jQCon San Francisco 2012
livelogos
 
Choosing the best JavaScript framework/library/toolkit
Choosing the best JavaScript framework/library/toolkitChoosing the best JavaScript framework/library/toolkit
Choosing the best JavaScript framework/library/toolkit
Hristo Chakarov
 
jQuery Foundation Keynote
jQuery Foundation KeynotejQuery Foundation Keynote
jQuery Foundation Keynote
Richard Worth
 
SlickGrid Touch: Making complex JavaScript widgets work on mobile devices
SlickGrid Touch: Making complex JavaScript widgets work on mobile devicesSlickGrid Touch: Making complex JavaScript widgets work on mobile devices
SlickGrid Touch: Making complex JavaScript widgets work on mobile devices
reebalazs
 

Mais procurados (20)

Sizzle jQCon San Francisco 2012
Sizzle jQCon San Francisco 2012Sizzle jQCon San Francisco 2012
Sizzle jQCon San Francisco 2012
 
Unit testing
Unit testingUnit testing
Unit testing
 
The Onion
The OnionThe Onion
The Onion
 
Angular vs React: Building modern SharePoint interfaces with SPFx
Angular vs React: Building modern SharePoint interfaces with SPFxAngular vs React: Building modern SharePoint interfaces with SPFx
Angular vs React: Building modern SharePoint interfaces with SPFx
 
JavaScript MV* Framework - Making the Right Choice
JavaScript MV* Framework - Making the Right ChoiceJavaScript MV* Framework - Making the Right Choice
JavaScript MV* Framework - Making the Right Choice
 
AngularJS + React
AngularJS + ReactAngularJS + React
AngularJS + React
 
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneJavascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
 
Mvvm knockout vs angular
Mvvm knockout vs angularMvvm knockout vs angular
Mvvm knockout vs angular
 
Latest Javascript MVC & Front End Frameworks 2017
Latest Javascript MVC & Front End Frameworks 2017Latest Javascript MVC & Front End Frameworks 2017
Latest Javascript MVC & Front End Frameworks 2017
 
jQuery Mobile Overview - Boston
jQuery Mobile  Overview -  BostonjQuery Mobile  Overview -  Boston
jQuery Mobile Overview - Boston
 
Choosing the best JavaScript framework/library/toolkit
Choosing the best JavaScript framework/library/toolkitChoosing the best JavaScript framework/library/toolkit
Choosing the best JavaScript framework/library/toolkit
 
AngularJS is awesome
AngularJS is awesomeAngularJS is awesome
AngularJS is awesome
 
JS Framework Comparison - An infographic
JS Framework Comparison - An infographicJS Framework Comparison - An infographic
JS Framework Comparison - An infographic
 
Top java script frameworks ppt
Top java script frameworks pptTop java script frameworks ppt
Top java script frameworks ppt
 
jQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchAppsjQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchApps
 
A team 43 C
A team 43 CA team 43 C
A team 43 C
 
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
 
jQuery Foundation Keynote
jQuery Foundation KeynotejQuery Foundation Keynote
jQuery Foundation Keynote
 
SlickGrid Touch: Making complex JavaScript widgets work on mobile devices
SlickGrid Touch: Making complex JavaScript widgets work on mobile devicesSlickGrid Touch: Making complex JavaScript widgets work on mobile devices
SlickGrid Touch: Making complex JavaScript widgets work on mobile devices
 
Wulin kungfu final
Wulin kungfu finalWulin kungfu final
Wulin kungfu final
 

Destaque (8)

jQuery Conference Toronto
jQuery Conference TorontojQuery Conference Toronto
jQuery Conference Toronto
 
jQuery Foot-Gun Features
jQuery Foot-Gun FeaturesjQuery Foot-Gun Features
jQuery Foot-Gun Features
 
jQuery Conference Chicago - September 2014
jQuery Conference Chicago - September 2014jQuery Conference Chicago - September 2014
jQuery Conference Chicago - September 2014
 
PrairieDevCon 2014 - Web Doesn't Mean Slow
PrairieDevCon 2014 -  Web Doesn't Mean SlowPrairieDevCon 2014 -  Web Doesn't Mean Slow
PrairieDevCon 2014 - Web Doesn't Mean Slow
 
HTTP 2.0 - Web Unleashed 2015
HTTP 2.0 - Web Unleashed 2015HTTP 2.0 - Web Unleashed 2015
HTTP 2.0 - Web Unleashed 2015
 
State of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront ConferenceState of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront Conference
 
jQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web PerformancejQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web Performance
 
jQueryTO: State of jQuery March 2013
jQueryTO: State of jQuery March 2013jQueryTO: State of jQuery March 2013
jQueryTO: State of jQuery March 2013
 

Semelhante a Transforming Front-End Disaster Code™ Into A Maintainable Masterpiece

Brad Enterprise Solution Architect
Brad Enterprise Solution ArchitectBrad Enterprise Solution Architect
Brad Enterprise Solution Architect
Brad Travis
 
Flu3nt highlights
Flu3nt highlightsFlu3nt highlights
Flu3nt highlights
dswork
 
Wrangling Large Scale Frontend Web Applications
Wrangling Large Scale Frontend Web ApplicationsWrangling Large Scale Frontend Web Applications
Wrangling Large Scale Frontend Web Applications
Ryan Roemer
 
20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners
20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners
20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners
Craeg Strong
 

Semelhante a Transforming Front-End Disaster Code™ Into A Maintainable Masterpiece (20)

7 Redux challenges
7 Redux challenges7 Redux challenges
7 Redux challenges
 
Sexy React Stack
Sexy React StackSexy React Stack
Sexy React Stack
 
Vue3: nuove funzionalità, differenze e come migrare
Vue3: nuove funzionalità, differenze e come migrareVue3: nuove funzionalità, differenze e come migrare
Vue3: nuove funzionalità, differenze e come migrare
 
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
Challenges of angular in production (Tasos Bekos) - GreeceJS #17Challenges of angular in production (Tasos Bekos) - GreeceJS #17
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
 
Modular Web Applications With Netzke
Modular Web Applications With NetzkeModular Web Applications With Netzke
Modular Web Applications With Netzke
 
Daniel Steigerwald - Este.js - konec velkého Schizma
Daniel Steigerwald - Este.js - konec velkého SchizmaDaniel Steigerwald - Este.js - konec velkého Schizma
Daniel Steigerwald - Este.js - konec velkého Schizma
 
ReactJS or Angular
ReactJS or AngularReactJS or Angular
ReactJS or Angular
 
Brad Enterprise Solution Architect
Brad Enterprise Solution ArchitectBrad Enterprise Solution Architect
Brad Enterprise Solution Architect
 
Flu3nt highlights
Flu3nt highlightsFlu3nt highlights
Flu3nt highlights
 
Practical WebAssembly with Apex, wasmRS, and nanobus
Practical WebAssembly with Apex, wasmRS, and nanobusPractical WebAssembly with Apex, wasmRS, and nanobus
Practical WebAssembly with Apex, wasmRS, and nanobus
 
Wrangling Large Scale Frontend Web Applications
Wrangling Large Scale Frontend Web ApplicationsWrangling Large Scale Frontend Web Applications
Wrangling Large Scale Frontend Web Applications
 
Node.js meetup 17.05.2017 ember.js - escape the javascript fatigue
Node.js meetup 17.05.2017   ember.js - escape the javascript fatigueNode.js meetup 17.05.2017   ember.js - escape the javascript fatigue
Node.js meetup 17.05.2017 ember.js - escape the javascript fatigue
 
Node.js for enterprise - JS Conference
Node.js for enterprise - JS ConferenceNode.js for enterprise - JS Conference
Node.js for enterprise - JS Conference
 
Cloud computing - an architect's perspective
Cloud computing - an architect's perspectiveCloud computing - an architect's perspective
Cloud computing - an architect's perspective
 
OOScss Architecture For Rails Apps
OOScss Architecture For Rails AppsOOScss Architecture For Rails Apps
OOScss Architecture For Rails Apps
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
Webpack
Webpack Webpack
Webpack
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
 
What Web Framework To Use?
What Web Framework To Use?What Web Framework To Use?
What Web Framework To Use?
 
20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners
20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners
20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

Transforming Front-End Disaster Code™ Into A Maintainable Masterpiece