Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Your Code Sucks: Best Practices for Enterprise ...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Arthur Kay
August 15, 2012
Programming
2.7k
8
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Your Code Sucks: Best Practices for Enterprise JavaScript Development
From ThatConference 2012
Arthur Kay
August 15, 2012
Transcript
54 slides
Best Practices for Enterprise JavaScript Applications YOUR CODE SUCKS
WHO AM I? • Arthur Kay • Solutions Engineer @
Sencha, Inc. • Web Development ~15 years • www.akawebdesign.com • @arthurakay
AGENDA • Improving application performance • Increasing code stability •
Scaling applications for enterprise • Tools • Advice
None
IMPROVING APPLICATION PERFORMANCE Part 1
CACHING
THIS CODE SUCKS
DO THIS INSTEAD • Cache values (references) • Avoid using
document.getElementById() and other global queries
DO THIS INSTEAD
OVER NESTING
THIS CODE SUCKS
DO THIS INSTEAD • Use lightweight containers (reduce DOM) •
Lazy Rendering
DO THIS INSTEAD
MEMORY LEAKS
THIS CODE SUCKS
DO THIS INSTEAD
INCREASING CODE STABILITY Part 2
SYNTAX ERRORS
THIS CODE SUCKS
DO THIS INSTEAD • Use JSLint (or something else) •
AUTOMATE SYNTAX CHECKING
ONE CLASS PER FILE
THIS CODE SUCKS
DO THIS INSTEAD • Organize your file system • Files
and folders should match namespacing • MVC (or something) • Development loader / Production builder
NAMES HAVE MEANING
THIS CODE SUCKS
DO THIS INSTEAD • Descriptive names on everything (except iterators)
• Common naming conventions (camelCase vs TitleCase vs nocase) • Exceptions for • constants ( SOME_CONSTANT ) • constructors ( MyClass ) • sub-namespaces ( Foo.bar.Class )_
COMMENTS / DOCUMENTATION
THIS CODE SUCKS
DO THIS INSTEAD • Comment top-level structures • Add notes
whenever logic is not obvious • Build your docs into a searchable tool
SCALING APPLICATIONS FOR ENTERPRISE Part 3
AVOID DUPLICATION
THIS CODE SUCKS
DO THIS INSTEAD • Abstraction! • Use mixins when possible
• Apply stuff to prototypes • Have similar classes/methods? • call() and apply()
DO THIS INSTEAD
SMALLER FILES. WHITE SPACE.
THIS CODE SUCKS
DO THIS INSTEAD • Keep methods under 50 lines •
Keep files under 500 lines • Use as much whitespace as possible.
UNIT TESTS
THIS CODE SUCKS
DO THIS INSTEAD • Write “testable” code • Focus on
important / trouble areas • AUTOMATE UNIT TESTING • Don’t insist on UI (integration/iteraction) tests * Test Driven JavaScript Development by Christian Johansen
TOOLS Stuff You Should Know About
IDE
INSPECT ELEMENT
YSLOW
JS DUCK
PHANTOM.JS
ADVICE Things I’ve Learned
SPECIFICATION – NOT TDD
NEVER STOP LEARNING
BREAK (SOME) RULES
None
ADDITIONAL RESOURCES • “Maintainable JavaScript” by Nicholas Zakas • http://www.slideshare.net/nzakas/maintainable-javascript-2012
• “Code Conventions for JS” by Douglass Crockford • http://javascript.crockford.com/code.html • “JavaScript Performance Tips & Tricks” by Grgur Grisogono • http://moduscreate.com/javascript-performance-tips-tricks/
THANKS! Arthur Kay | @arthurakay
SPEAKERDECK.COM/U/ARTHURAKAY Share this presentation:
More Decks by Arthur Kay
See All by Arthur Kay
Analyzing the ROI of JavaScript in Enterprise Software Development
arthurakay
0
190
Debugging your Apps with Google Chrome and Sencha
arthurakay
1
330
Announcing Ext JS 5
arthurakay
0
180
Conquering the Command Line
arthurakay
0
390
The Future of Enterprise App Development
arthurakay
0
170
Best Practices for Enterprise JavaScript Applications
arthurakay
7
2.6k
Bringing the Mobile Web to the Cloud
arthurakay
2
620
Building Native Windows 8 Apps with Sencha
arthurakay
0
290
Creating Windows 8 Apps with Ext JS
arthurakay
1
320
Other Decks in Programming
See All in Programming
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
140
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
110
AI駆動開発4年目の現在地(『あなたはFDEになるべきか?』イベント資料)
kumaiu
0
660
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
170
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
200
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
360
AI時代のIaC入門 〜なぜインフラをコードで管理したいのか?〜 / Introduction to IaC in the AI Era
akihisaikeda
6
1.5k
flutter_test のその先へ — Flutter アプリの LLM 機能に「評価」という品質保証を
kosukesaigusa
0
200
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
1
300
SODA - FACT BOOK(EN)
sodainc
1
260
Snowflake Openflow Connector利用の勘所 / 20261024developersio2026tokyo-snowflake-openflow
kasacchiful
PRO
0
350
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
320
Featured
See All Featured
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
310
A Soul's Torment
seathinner
9
3.9k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
We Have a Design System, Now What?
morganepeng
55
8.4k
Prompt Engineering for Job Search
mfonobong
0
590
Ethics towards AI in product and experience design
skipperchong
2
470
Automating Front-end Workflow
addyosmani
1370
210k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
300
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.9k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
It's Worth the Effort
3n
188
29k