Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^8: a State machine with Roles - possible? (class or instance)

by mascip (Pilgrim)
on Jun 01, 2013 at 10:33 UTC ( #1036411=note: print w/ replies, xml ) Need Help??


in reply to Re^7: a State machine with Roles - possible? (class or instance)
in thread a State machine with Roles - possible?

And that's where Class::StateMachine::Declarative shines: it's concise, and makes it easy for humans to apprehend the whole transitions set.

I realise now that objects, if they have several attributes, ARE multidimensional state machines anyway. My question was thus mostly about whether it is possible to unapply a Role; thinking that it could be useful some day.

Just one last quesiton: Is it possible to use Class::StateMachine in a Role?


Comment on Re^8: a State machine with Roles - possible? (class or instance)
Re^9: a State machine with Roles - possible? (class or instance)
by salva (Monsignor) on Jun 01, 2013 at 11:25 UTC
    Class::StateMachine::Declarative is the result of my experience developing complex state machines, but for my current kind of problems that may be quite specific, I don't know how that could bend to the problems of other people.

    I am still not completely happy with it, but it is true that the current iteration is much better than its predecessors.

    Is it possible to use Class::StateMachine in a Role

    No, because Class::StateMachine is a metaclass, it plays with the method resolution order (mro) to attain the specific state machine method resolution.

    When I designed Class::StateMachine I have a hard time figuring how support the state machine while retaining the full perl object oriented semantics (specifically inheritance and multiple inheritance). But then, when I got to use it for practical matters, I discover that inheritance and state machines do not mix well.

    Thinks like defining some states in one class, and others in a subclass, or refining them in the subclass is not a great idea.

    It is ok to reuse (via inheritance or roles) the code that implements simple actions, but the state machine definition should be a coherent entity.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1036411]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2014-10-21 09:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (99 votes), past polls