Trying to push forward the discussion about Web UI with state machines. I came 
up with the following decomposition of the core components of a web application 
:

- application state
- application data
- business logic
- ui logic
- event processing
- presentation layer
- routing

In this schema, I think the application state is the real core, because every 
other components is directly related to it, at least if you use a state 
machine. I came up with the following model.

- application data : related to application state because both can easily 
represented as data. If we want a web app that is completely state-driven (I 
want this, for debugging, testing and time-travel capabilities), simply merge 
the data and the state in the same data entity.

- business logic/ui logic : in a state machine there's the notion of "actions" 
executed with each transition (where necessary). So the logic could just be 
executed by the state machine itself.

- event processing : a state machine can be event-driven, and this a perfect 
match with a web app since the web (and any UI for that matter) is inherently 
event driven. So the event/input of the state machine could just match the 
event triggered by the user, as well as custom events if necessary.

- presentation layer : simply display the current app-state as HTML/CSS. In the 
React.js model, it would simply mean updating the app state and letting React 
render everything.

- routing : this is where stuff gets complicated in my mind. In a proper 
application, lot of state is derived from the URLs. But not all state, for 
instance whether a modal is displayed or not, or whether a form is validated 
client side or not isn't tied to a URL. Which tend to let me think that there's 
some kind of hierarchy in the state machine. The URLs could be represented as 
events as well in the state machine, but could happen at anytime, whereas other 
events and related transition depend on the current state in a state machine. 
So it's like you have a top-level state machine for URLs, and each URL has its 
own state machine for all interactions in the page. Maybe page-state machine 
could be refined in multiple levels state machines too, not sure about that. It 
seems like Hierarchical State Machine may help here, but I haven't studied the 
subject yet at all.

What do you think ?

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to