Hi, I'm currently writing my master's thesis on how state machines can be used to describe complex user interface behaviour. Michel Beaudoin-Lafon has a good paper on the motivation for this:
http://portal.acm.org/citation.cfm?id=989865 To summarize, most general-purpose programming languages are fundamentally at the wrong level of abstraction for describing certain kinds of user interface behaviour. Consider the example of drag-and-drop behaviour. To implement this in JavaScript, you would likely register three callback functions, for mousedown, mouseup, and mousemove, respectively. You would also keep a variable outside of these functions to keep track of changes in application state between these callbacks. You would probably end up with something like the following snippet: var state; node.addEventListener("mousedown",function(e){ state = "DRAGGING"; },false); node.addEventListener("mouseup",function(e){ state = "IDLE"; },false); node.addEventListener("mousemove",function(e){ if(state === "DRAGGING"){ //move the node based on e } },false); The problem is that this approach does not scale very well as applications become increasingly complex, especially for applications that involve a complex notion of state. The reason for this is that, what conceptually is a single interaction (drag-and-drop) is broken up across a number of callbacks which are not explicitly linked in the syntax of the language. What you would like is to be able to describe the drag-and-drop interaction holistically, but what you end up with instead is a spaghetti of callbacks linked by global variables. A language at the right level of abstraction would be able to encode explicitly the notion of the state of an object changing in reaction to events. Finite state machines or Statecharts provide such a language, and in fact, state machines have a long history of use in human-computer interaction research to describe user interface behaviour. In order to use Statecharts in the web environment, they must first be compiled to JavaScript. This is the motivation for my project, SCXML-JS, an optimizing Statechart-to-JavaScript compiler. This work is still under heavy development, but more information can be found at the following links: http://commons.apache.org/sandbox/gsoc/2010/scxml-js/ http://www.svgopen.org/2010/registration.php?section=abstracts_and_proceedings#paper_45 http://www.svgopen.org/2009/registration.php?section=abstracts_and_proceedings#paper_36 If anyone has any questions about this work, please feel free to contact me off-list, or on the Apache Commons mailing list. Cheers, Jake -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
