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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
geoffreyd
February 28, 2012
Programming
1
160
What Do You Know: StateCharts
Presentation for the WebDirections What Do You Know night.
geoffreyd
February 28, 2012
Tweet
Share
Other Decks in Programming
See All in Programming
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
CSC307 Lecture 02
javiergs
PRO
1
780
Oxlintはいいぞ
yug1224
5
1.3k
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
7.4k
並行開発のためのコードレビュー
miyukiw
0
260
要求定義・仕様記述・設計・検証の手引き - 理論から学ぶ明確で統一された成果物定義
orgachem
PRO
1
140
Apache Iceberg V3 and migration to V3
tomtanaka
0
160
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
460
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
3.9k
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
2.5k
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
130
AIによる開発の民主化を支える コンテキスト管理のこれまでとこれから
mulyu
3
360
Featured
See All Featured
From π to Pie charts
rasagy
0
120
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
76
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
93
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
730
Unsuck your backbone
ammeep
671
58k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
750
Code Review Best Practice
trishagee
74
20k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
94
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
97
Leo the Paperboy
mayatellez
4
1.4k
Evolving SEO for Evolving Search Engines
ryanjones
0
130
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
410
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