Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Building large JS apps
Search
Alex MacCaw
May 31, 2012
Programming
2.3k
20
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Building large JS apps
Alex MacCaw
May 31, 2012
More Decks by Alex MacCaw
See All by Alex MacCaw
Fronteers
maccman
0
160
A JavaScript Web App Deconstructed
maccman
6
610
Asynchronous Web Interfaces
maccman
16
2.1k
Spine
maccman
11
1.3k
Other Decks in Programming
See All in Programming
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
650
Introducing Stack Pull Request in GitHub
kkamegawa
0
110
Cloudflare is Agents
chimame
0
180
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
100
プロポーザルを書いてもらう
pvcresin
0
590
Oxlintはいいぞ(続)
yug1224
1
480
ALB ログから Trace を気合で繋げる技術
fohte
7
770
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
5
550
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
290
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
370
Deep dive into the select statement (GopherCon UK)
jespino
0
150
typoなんかねぇよ
raspython3
0
610
Featured
See All Featured
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.1k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
630
Believing is Seeing
oripsolob
1
200
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Designing Powerful Visuals for Engaging Learning
tmiket
1
510
Docker and Python
trallard
47
4.2k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
210
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
520
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
250
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
480
Transcript
@maccman May 2012
I am @maccman (not @mccman)
I like CoffeeScript
Building hardware
None
None
Redundancy means decoupled components
This talk isn’t really about Spine
...or about Backbone
It’s about mega.js
Or base.js
Or everythingbutthekitchensink.js
Its about structure and building large apps
CommonJS?
1. Exposing properties
2. Requiring modules
module.exports = User; require('user');
If you’re not using a module system, like CommonJS, you’re
doing it wrong
sprockets-commonjs
program.module.js
module.exports = function(){ alert('Long live the Programs!'); };
this.require.define({"modules/program": function(exports, require, module){ module.exports = function(){ alert('Long live the
Programs!'); }; }});
this.require.define({"modules/program": function (exports, require, module) { module.exports = function ()
{ alert('Long live the Programs!') } }})
Program = require('modules/program')
sprockets-source-url
eval("..." + "\n//@ sourceURL=/application");
None
None
Stylo
None
styloapp.com
github.com/maccman/stylo
None
None
None
None
“The secret to building large apps is never build large
apps. Break your app into small pieces. Then, assemble those testable, bite- sized pieces into your big application.” - Justin Meyer
None
H e a d e r Stage Element Element Dimensions
Background Border Border Radius Shadow Opacity Inspector
None
None
None
None
Abstract components
Treat them like open source libraries
Color Picker Position Picker Context Menu
Decoupled controllers
Rules
1. Controllers can be instantiated multiple times without adverse effects
2. Controllers work without being attached to the DOM
Initially stored state in the DOM
None
Store state in the controllers, not the models, not the
view
Styles
No IDs
Separate stylesheets for each controller
None
Clear over DRY
#app .inspector .background { .edit { margin: 10px } .gradientPicker
{ margin: 0px 5px 5px 5px } &.disabled { .list { opacity: 0.6 } } }
Module communication
Expose a simple API and use events
// Private
PubSub
// color_picker.js this.trigger('change');
// background.js var colorPicker = new ColorPicker; colorPicker.bind('change', function(color){ //
... }); this.append(colorPicker);
Children should’t know anything about their parents
What I learnt
Use the tools
Awesome debugger
None
None
None
Shortcuts
None
$0
Memory leaks
None
None
None
display: none;
Less DOM manipulation
mousemove handlers need to be fast
None
requestAnimationFrame()
var Inspector = function(){ this.stage.selection.bind('change', this.paint.bind(this)); }; Inspector.prototype.paint = function(){
if (this.rendering) return; this.rendering = true; requestAnimationFrame(this.render.bind(this)); }; Inspector.prototype.render = function(){ // ... this.rendering = false; };
Most importantly
Advanced doesn’t mean complicated
Use simple building blocks
Tackle large problems by splitting them up
@maccman
Follow @fakeangus