Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Interface design question: graphing state machines.

by Ovid (Cardinal)
on Dec 20, 2004 at 22:48 UTC ( #416346=perlquestion: print w/replies, xml ) Need Help??

Ovid has asked for the wisdom of the Perl Monks concerning the following question:

Note: If you're unfamiliar with state machines, this article should give you the necessary background. Also, a variant of this question was cross-posted to the module authors list.

I've been doing a lot of work with FSA::Rules for my job. I've added GraphViz support to generate state machine graphs on the fly.

To do this, here's how a state is defined (see the module for a full explanation):

installed => { do => sub { shift->result($self->_is_installed) }, rules => [ fail => { "Postgres not\ninstalled" => sub {! shift->result } + }, version => { "Postgres\ninstalled" => sub { shift->result } }, ], },

Each rule now takes an optional hash reference. If supplied, the key is the "label" that appears on the line leading from state to state (take a look at the first state on the linked graph and notice the names.)

If you prefer, you can also specify the rules the old way:

rules => [ fail => sub { ! shift->result }, version => sub { shift->result } ],

The only difference is that there is no label if a graph is generated. In other words, for rules you can use a subref or a hashref. Does that sound confusing? I think it is.

Can anyone suggest a cleaner syntax for the rule labels? Having state machine graphs auto-generated is really cool, but I don't know if it's worth the expense of making things too confusing to use. Because we're struggling with the syntax, we have not yet uploaded the version with GraphViz support.

As a side note, if you would prefer a completely different syntax for the module, we're open to anything that will make it easier to use, even though it's already pretty easy.


New address of my CGI Course.

Replies are listed 'Best First'.
Re: Interface design question: graphing state machines.
by tilly (Archbishop) on Dec 20, 2004 at 22:57 UTC
    One very random suggestion. You might get some ideas from poking around libero. I'm not suggesting that you want to use it, I'm merely suggesting that seeing how other people have tackled your problem (enable people to write programs by writing a state machine first) may give you ideas on how to do it or not do it.

    All that I really know about that development environment is that it was how the Xitami webserver was developed.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://416346]
Approved by Old_Gray_Bear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2020-10-20 07:17 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (209 votes). Check out past polls.