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
Why you should use a MV* framework
Search
Joël Cox
April 19, 2013
Programming
2
610
Why you should use a MV* framework
Presented at Codee (
http://cod.ee
.)
More from me about
business and technology
.
Joël Cox
April 19, 2013
Tweet
Share
More Decks by Joël Cox
See All by Joël Cox
Pixelpillow College Tour - HTTP APIs
joelcox
0
13
Pixelpillow College Tour - Call me Maybe
joelcox
0
18
Pixelpillow College Tour - Grafen, automaten en reguliere talen
joelcox
0
49
CI Joe
joelcox
0
54
Shipping products in a start-up environment
joelcox
0
55
Measuring Dependency Freshness in Software Systems
joelcox
0
94
(Really) naive data mining
joelcox
2
510
Deploying large scale web applications
joelcox
1
250
Other Decks in Programming
See All in Programming
What We Can Learn From OSS
inouehi
0
420
Random\Randomizer クラスで日常のあれこれを解決しよう! / Random\Randomizer class solves familiar trouble
cocoeyes02
0
230
大規模UIKitベースアプリへのTCAの段階的導入/gradual-adoption-of-tca-in-a-large-scale-uikit-based-app
takehilo
1
140
Milestoner
bkuhlmann
1
410
PHP8.3の機能を振り返る / Review of PHP 8.3 features
seike460
PRO
1
110
ONE WEDGE_company_guide
1wedge_one
0
470
使ってみよう Azure AI Document Intelligence
kosmosebi
2
300
Git Rebase
bkuhlmann
11
1.6k
TYPO3 v13 – The road to LTS: What's new and new APIs
luisasofie_xoxo
0
200
スキーマ駆動開発による品質とスピードの両立 - 私達は何故、スキーマを書くのか
kentaroutakeda
0
170
Micro Frontends for Java Microservices - Devnexus 2024
mraible
PRO
0
490
SwiftUIで使いやすいToastの作り方 / How to build a Toast system which is easy to use in SwiftUI
lovee
3
140
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
260
12k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
19
1.7k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
17
1.4k
Statistics for Hackers
jakevdp
789
220k
How To Stay Up To Date on Web Technology
chriscoyier
782
250k
VelocityConf: Rendering Performance Case Studies
addyosmani
320
23k
Web development in the modern age
philhawksworth
202
10k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
18
6.9k
Art, The Web, and Tiny UX
lynnandtonic
289
19k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
60
14k
Transcript
WHY YOU SHOULD USE A CLIENT-SIDE MV FRAMEWORK Joël Cox
joelcox.nl @joelcox ˒
Who is this kid? (And why should I listen to
him?)
None
- Where are we coming from? - What are the
challenges? - Where are we heading?
VERY LITTLE CODE AHEAD WARNING:
Once upon a time, a team at a small so
ware company in Redmond, USA set out to make the web a bit more dynamic...
XMLHttpRequest
XMLHttpRequest be er known as AJAX
Other browsers adopted the new “standard”and we lived happily ever
a er.
Other browsers adopted the new “standard”and we lived happily ever
a er?
How many people here consider themselves to be experienced jQuery
programmers?
How many people here consider themselves to be experienced JavaScript
programmers?
$.post('api/endpoint', {key: value}, { success: function(data) { $('#container').appendTo(data.message); $.get('api/endpoint/' +
data.id, function(data) { $.get('api/endpoint/2', function(data) { // More callbacks }); }), }, error: function(errorMessage) { $('#container').appendTo(errorMessage); // More callbacks, again. }); } });
Somehow jQuery made us forget about good practices (callbacks ain’t
bad, but not 5 levels deep)
And now you want to make rich, desktop-like, web applications
and then shit hits the fan
Didn’t we see that before?
<html> <head> <title>Articles</title> <?php if (isset($_COOKIE['auth'])) header('/login'); $article = $db->get_results('SELECT
* FROM pages WHERE id = "' . mysql_string_escape($_GET['id'] . '"'); ?> </head> <body> <?php foreach ($articles as $article): ?> <h1><?= $article->title ?></h1> <em>By <?= $article->author ?></em> <?= format_body($article->content) ?> <?php endforeach ?> </body> </html>
MVC
Model (data) Controller (request) View (layout)
Traditional web MVC does all this work on the server
Client-side MV frameworks put all this functionality in the browser
˒
Model (data) Controller (request) View (UI) Template (layout)
˒ ?
- Where are we coming from? - What are the
challenges? - Where are we heading?
None
Lesson #1 Brush up your JS skills, big time
Why is function suddenly undefined for this?
... Server.prototype.bindListeners = function() { this.socket.on('data', this.processData); }; Server.prototype.doSomething =
function(part) { ... }; Server.prototype.processData = function(data) { this.doSomething(data); }; > TypeError: Object #<Object> has no method 'doSomething'
... Server.prototype.bindListeners = function() { this.socket.on('data', this.processData); }; Server.prototype.doSomething =
function(part) { ... }; Server.prototype.processData = function(data) { this.doSomething(data); }; > TypeError: Object #<Object> has no method 'doSomething' this refers to socket, not Server
... Server.prototype.bindListeners = function() { this.socket.on('data', this.processData.bind(this)); }; Server.prototype.doSomething =
function(part) { ... }; Server.prototype.processData = function(data) { this.doSomething(data); }; > TypeError: Object #<Object> has no method 'doSomething'
“Learning JavaScript with Object Graphs” on How To Node “Understanding
bind and bindAll [in Backbone.js]” on Big Binary
Lesson #2 Todo apps don’t give you the whole story
Nested views; how do the different frameworks handle this ?
(Hints: Zombie views and rerender all the things!)
Lesson #3 Flexibility is killer
Use something like Marione e.js for additional structure
Lesson #4 Listen to the experts (Derek Bailey, Addy Osmani,
Tom Dale)
“The best programmers are the quickest to Google” – Vu
Tran
Lesson #5 Refactor, refactor, refactor.
Not tackeling stuff right now will leave you with huge
technical debt
- Where are we coming from? - What are the
challenges? - Where are we heading?
Shared codebase between client and server (h ps://github.com/airbnb/rendr)
API Driven Development (h p://alexbilbie.com/2013/03/api-driven-development-talk/)
Fin. Thanks for listening!