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
What Do You Know: StateCharts
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
geoffreyd
February 28, 2012
Programming
170
1
Share
What Do You Know: StateCharts
Presentation for the WebDirections What Do You Know night.
geoffreyd
February 28, 2012
Other Decks in Programming
See All in Programming
JavaDoc 再入門
nagise
0
280
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
4
1.4k
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
110
RTSPクライアントを自作してみた話
simotin13
0
470
tsserverとは何だったのか、これからどうなるのか
nowaki28
1
450
AI時代のUIはどこへ行く?その2!
yusukebe
19
6.6k
さぁV100、メモリをお食べ・・・
nilpe
0
130
TypeSpec で繋ぐ複数プロダクトの型安全
maroon8021
1
370
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
720
Moments When Things Go Wrong
aurimas
3
140
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
540
dRuby over BLE
makicamel
2
310
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Automating Front-end Workflow
addyosmani
1370
210k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
820
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Designing Powerful Visuals for Engaging Learning
tmiket
1
400
Faster Mobile Websites
deanohume
310
31k
The untapped power of vector embeddings
frankvandijk
2
1.7k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.3k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
350
How to train your dragon (web standard)
notwaldorf
97
6.7k
Transcript
Simplify your Events Geoffrey Donaldson @geoffreyd
So you’re building an App?
The Cool Cats Say • Design: MVC, MVVM, MVP •
Framework: Backbone, Batman, Sammy, SproutCore, JavascriptMVC ... • Templates: Handlebars, Moustache, Jade, Plain old HTML ...
View View Controller Model
View View Controller Model
View View Controller Model
Data View Controller Model
Data View Controller Model
Events ? View Controller Model
Events ? View Controller Model
Events ? View Controller Model
Errrr
Events ? View Controller Model
Events ? View Controller Model
Which One? Views User Controller Models Contact Controller Client Controller
Booking Controller Login Controller
StateCharts Logic Controllers for your App Login (Is NOT logged
in) CHECK AUTHORIZATION endLogin Show Login Running (Is Logged in) beginLogin
Which One? Views Models User Controller Contact Controller Client Controller
Booking Controller Login Controller
StateCharts - Logic Controllers Views User Controller Models Contact Controller
Client Controller Booking Controller Login Controller StateChart
Data Goes to Views Views User Controller Models Contact Controller
Client Controller Booking Controller Login Controller StateChart
Events Goes to StateChart Views User Controller Models Contact Controller
Client Controller Booking Controller Login Controller StateChart
StateChart Respond to Events Views User Controller Models Contact Controller
Client Controller Booking Controller Login Controller StateChart
Responsible for View Setup Views User Controller Models Contact Controller
Client Controller Booking Controller Login Controller StateChart
So How does it work? Show me already!!
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin statechart.addState({ parentState: “App”, name: “login”, initialSubState: “checkAuthorization” })
statechart.addState({ name: “checkAuthorization”, parentState: “login”, enterState: function() { if (userLoggedIn())
{ this.goToState(“Running”) } else { this.goToState(“ShowLogin”) } } }) Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login Running (Is Logged in) beginLogin
statechart.addState({ name: “showLogin”, parentState: “login”, enterState: function() { // Show
Login View }, exitState: function() { // Hide Login View }, beginLogin: function() { // Send data to server }, endLogin: function() { // Receive response, Then go to Running State } }) Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login Running (Is Logged in) beginLogin
statechart.addState({ name: “Running”, parentState: “App”, enterState: function() { // Show
App Views }, exitState: function() { // Hide App Views } }) Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login Running (Is Logged in) beginLogin
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin Testing
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin Testing Pass 1 Logged Out, Successful response
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin Pass 1 Logged Out, Successful response Pass 2 Logged Out, Failed response Testing
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin Pass 1 Logged Out, Successful response Pass 2 Logged Out, Failed response Pass 3 Already Logged In Testing
Login (Is NOT logged in) CHECK AUTHORIZATION endLogin Show Login
Running (Is Logged in) beginLogin Pass 1 Logged Out, Successful response Pass 2 Logged Out, Failed response Pass 3 Already Logged In Testing DONE!
StateCharts • Put your App logic in the right place
• Each State is responsible for it’s visual state • Separate concerns • Easy to Test
StateCharts You to can use them github.com/etgryphon/stativus