extensible State Machines

One of the problems in web application design is the disconnect between traditional programming languages and the statelessness of the web. There are ways to work around this, storing session information in hidden fields, setting cookies and tracking session information there or on the server. There are languages designed for the web such as PHP and ASP. Traditional languages are made to work with the web: Java and Perl being two big examples. But none of these capture the nature of the client/server model fundamental to web applications. All of them require some reinvention of the wheel each time an application is built.

Written in an XML language, eXtensible State Machines (XSM) are the controllers in a Model-Controller-View design. They describe what an application can do when in a particular state by detailing what information will allow the application to change to another state and how the business logic is brought into play when the application transitions between two states. The resulting state of the application determines which view is presented to the customer. Session management, state and data persistence are all handled seamlessly behind the scenes of the application.

The basic XSM skeleton is a set of states and transitions:

But XSLT can't provide our business logic. That's where we get to the eXtensible part of XSM. By defining libraries of tags (taglibs), we can create the glue between our controllers and our business logic, application servers, databases, etc. The core of XSM is concerned with describing the general flow and structure of the application. The scripting and taglib extensions allow it to interact with the rest of the business system.

For more information on XSM, please look at the Gestinanna distribution on CPAN . This system is a work in progress, but with a little work can already run some simple applications. I'll write more in-depth about XSM and taglibs in another post.