On Wed, Dec 15, 2004 at 10:08:43AM -0000, Orton, Yves wrote:
> > Ovid and I were getting fed up with the horrible DFA::Simple module, so  
> > I wrote a new module, DFA::StateMachine, to take its place in our work.  
> > But I'm no computer scientist, so I'm not even sure whether the name is  
> > right or if the module functions the way a DFA state machine is  
> > supposed to behave. 
> 
> [...]
> Maybe: FSA::Rules is better?

There's a Computer::Theory::FSA module already:
http://search.cpan.org/~frighetti/Computer-Theory-FSA-0.1_05/lib/Computer/Theory/FSA.pm
but it doesn't look pleasant to use.

FSA::Rules seems okay, but it doesn't express the simple utility
of the module. I hate to suggest FSA::Simple but it almost seems
appropriate here.

> Having said that it looks like an interesting module. Id be curious as to
> what you use it for tho.

I'm looking for a simple FSA module to help manage states in a GUI.

Some quick observations:

 - I'd prefix some of the actions with "on_"
        on_enter => sub { ...},
        on_leave => sub { ...},
   because they don't 'perform' the enter/leave they're just triggered by it.

 - The docs aren't very clear about when "do" actions are run.
   They talk about "while in the state" and "in the state".
   Saying "after entering the state" would be more clear.

 - Using undef to mean 'always' in the goto rules is confusing.
   Using 1 (or any true scalar) would seem more natural.

 - Hooks for tracing execution would be helpful.
   Using empty methods and requiring users to sub-class would suffice.

 - There's scope for refactoring into finer-grained methods.

 - I'd suggest renaming check() to attempt_transition() and have it return
   the new state or undef (not croak) if it can't transition at the moment.

 - Then define check() to be { self->attempt_transition() || croak ... }
   But a better name than check() would also be good.

 - Looks good!

Any idea how soon it might reach CPAN once a name is chosen?

Tim.

Reply via email to