4 ms·
Yes! State machines are a natural paradigm for complex UIs. Event handlers are great as long as they remain independent little globs of code: this button turns
by gruseom 14y ago
Yes! State machines are a natural paradigm for complex UIs.
Event handlers are great as long as they remain independent little globs of code: this button turns that thing off, this click makes that color different, etc. But once they start affecting each other at a distance (e.g., the button starts some action that temporarily changes the meaning of the click), you need a method of controlling the effects systematically or you end up with spaghetti. Pretty much every complex UI I've ever seen is that spaghetti.
MVC is too simplistic to give this. M means "state" and V means "what the user sees" and C means "just make it all work, mkay?", which lets you down right where you need an organizing principle.
I struggled with UI spaghetti for years before finally realizing that state machines are a nice systematic way to manage this complexity. Now it seems kind of obvious that UIs are state machines. They're machines and they have state!
- deleted 14y ago[deleted]
- jff 14y agoState machines are this neat thing they teach you in freshman Computer Engineering courses, but I've met a lot of CS or SE graduates who have no idea, which is too bad--they're a useful tool. Anyone who doesn't know state machines should definitely read up on them.