Video and slides synchronized, mp3 and slide download available at http://bit.ly/YL91yo.
Daniel Erickson addresses the problems appearing in mixing MVC and real time frameworks in web applications and how Geddy transparently solves these issues. Filmed at qconsf.com.
Daniel Erickson has spent the better part of the last 8 years evolving with the web. He currently works for Yammer as a Senior JavaScript Engineer. He is a core contributor for Geddy, one of the leading web frameworks for Node.js. He has been working with Node since it's early days back in 2010, and has worked with a number of companies to help them write well organized Node applications.
DevEX - reference for building teams, processes, and platforms
RT-MVC: Real Time Model/View/Controller Applications
1. 11/7/12 Real Time and MVC with GeddyJS
1/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
RT-MVC
Real Time Model/View/Controller Applications
/Daniel Erickson qConSF
2. InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
http://www.infoq.com/presentations
/Real-Time-MVC-Geddy
3. Presented at QCon San Francisco
www.qconsf.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
4. 11/7/12 Real Time and MVC with GeddyJS
2/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT'S GOING TO
WIN
REAL TIME OR MVC?
5. 11/7/12 Real Time and MVC with GeddyJS
3/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
REAL TIME?
6. 11/7/12 Real Time and MVC with GeddyJS
4/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
YEAH!
'CUZ SOME PEOPLE SAY:
MVC doesn't scale well
MVC is dead
7. 11/7/12 Real Time and MVC with GeddyJS
5/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
BUT MVC IS HERE TO STAY
Gives teams structure to get things done
Allows new people to jump into your project
Easy to get started with
8. 11/7/12 Real Time and MVC with GeddyJS
6/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT'S GOING TO
WIN
REAL TIME OR MVC?
9. 11/7/12 Real Time and MVC with GeddyJS
7/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
MVC?
10. 11/7/12 Real Time and MVC with GeddyJS
8/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
TOTALLY!
'CUZ PEOPLE THINK:
Real Time is hard
Maintain a new stack
Event Machine and Tornado suck
Front end code is messy
11. 11/7/12 Real Time and MVC with GeddyJS
9/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
BUT REAL TIME IS ALSO HERE TO STAY
Use WebSockets to get updates on the front end
Instant feedback for your users
Works really well on mobile
12. 11/7/12 Real Time and MVC with GeddyJS
10/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT'S GOING TO
WIN
REAL TIME OR MVC?
13. 11/7/12 Real Time and MVC with GeddyJS
11/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
BOTH!
14. 11/7/12 Real Time and MVC with GeddyJS
12/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
REAL TIME AND MVC
ACTUALLY MIX PRETTY WELL
15. 11/7/12 Real Time and MVC with GeddyJS
13/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
YOU CAN:
Define your model once and use it all over the place
use your templates on both sides of HTTP
Mirror events from the backend to the frontend
instance created
instace updated
instance removed
16. 11/7/12 Real Time and MVC with GeddyJS
14/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
HOW WE SOLVED THE
REAL TIME PROBLEM
WITH GEDDY
17. 11/7/12 Real Time and MVC with GeddyJS
15/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WAIT,
WHAT'S GEDDY?
18. 11/7/12 Real Time and MVC with GeddyJS
16/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
THE ORIGINAL MVC
FRAMEWORK FOR NODE.JS
Very familiar if you know Rails
Awesome noSQL and SQL ORM
Many different templating languages
19. 11/7/12 Real Time and MVC with GeddyJS
17/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
AND NOW IT
SUPPORTS REAL TIME
RIGHT OUT OF THE BOX
20. 11/7/12 Real Time and MVC with GeddyJS
18/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
SO LETS MAKE AN MVC APP
THAT SUPPORTS REAL TIME
21. 11/7/12 Real Time and MVC with GeddyJS
19/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
GENERATE AN APP
$ npm install -g geddy
$ geddy app -rt demo
$ cd demo
$ geddy scaffold -rt thing title description
$ geddy
22. 11/7/12 Real Time and MVC with GeddyJS
20/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
TEST IT OUT
Open up
and
http://localhost:4000/things
http://localhost:4000/things/add
23. 11/7/12 Real Time and MVC with GeddyJS
21/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
FOR THOSE OF YOU FOLLOWING
ALONG AT HOME
1. add a thing
2. watch it show up in the other window
3. update the thing
4. watch it change in the other window
5. remove the item
6. watch it get removed from the other window.
24. 11/7/12 Real Time and MVC with GeddyJS
22/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT JUST HAPPENED?
geddy app -rt demo
Generated a demoapp with realtime enabled
25. 11/7/12 Real Time and MVC with GeddyJS
23/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT JUST HAPPENED?
geddy scaffold -rt thing ...
Generated a thingresource
thingmodel
made that model available on the front end
thingscontroller
routes
views that subscribe to the realtime events
26. 11/7/12 Real Time and MVC with GeddyJS
24/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
HOW DOES IT WORK?
ON THE SERVER SIDE:
geddy sees the realtimeflag in your config file
copies your models over to a public js file
sets up listeners for each model's lifecycle events
proxies those lifecycle events to socket.io
27. 11/7/12 Real Time and MVC with GeddyJS
25/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
HOW DOES IT WORK?
ON THE CLIENT SIDE:
registers listeners for all model related events
proxies them to the appropriate models
scaffolds some code that hooks into real time events
28. 11/7/12 Real Time and MVC with GeddyJS
26/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
THATS PRETTY COOL,
BUT IS IT EASY TO CHANGE?
modify your model once and you get it everywhere
emit custom events on your models
all generated code can be modified
29. 11/7/12 Real Time and MVC with GeddyJS
27/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WHAT'S NEXT ON THE ROADMAP?
Create an AJAX adapter for the front-end ORM
Real time queries
Per instance real time events
A better way to share templates
30. 11/7/12 Real Time and MVC with GeddyJS
28/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
WANT TO HELP OUT?
CHECK OUT GEDDY AT
Join the mailinglist
open bugs on github
send us pull requests
http://geddyjs.org
31. 11/7/12 Real Time and MVC with GeddyJS
29/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1
ANY QUESTIONS?
32. 11/7/12 Real Time and MVC with GeddyJS
30/30file://localhost/Users/derickson/dev/presentations/2012/qconsf/index.html?print‑pdf#/1