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 LanX (Saint)
on Jun 01, 2013 at 11:13 UTC ( [id://1036418]=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?

I agree with you, that an intuitive API is the more important than implementation.

But do you have a real world example of a multidimensional state machine?

This "door" thing is just to shallow to justify the efforts and clarify advantages of different approaches.

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^9: a State machine with Roles - possible? (class or instance)
by salva (Canon) on Jun 01, 2013 at 11:38 UTC
    Yes, a real common example is, on an event-based application, an object that has to do two (or more) things at the same time. For instance accessing a network service while tracking and external process or accessing a database.

    You may be able to delegate most of the work needed to perform the subtasks to other objects (which would be unidimensional state machines). But there would be a point where you have to handle the interaction between them using a multidimensional state machine.

    In any case, note that a multidimensional state machine can be converted into a unidimensional one if you flatten the state matrix using the cartesian product, or in practice, if you are able to organize the states in a tree (usually not all the multidimensional states may happen).

      Thanks! =)

      > You may be able to delegate most of the work needed to perform the subtasks to other objects (which would be unidimensional state machines).

      This would be my first choice.

      The main object has attributes referencing the state objects.

      > But there would be a point where you have to handle the interaction between them using a multidimensional state machine.

      Thats where I would use "proxy"/wrapper methods in the class of the main object.

      Cheers Rolf

      ( addicted to the Perl Programming Language)

Re^9: a State machine with Roles - possible? (class or instance)
by mascip (Pilgrim) on Jun 01, 2013 at 11:22 UTC

    I don't have an example: it's just me playing with fire, and learning.

    The closest example that i found is here. It's a video game character that can be turned into a Zombie, poisoned (which could make her stronger if she's a zombie), turned into a Chipmunk, an Angel (which turns it into a Dead-Angel if it's also a Zombie), break a leg, or any combination of the above.

    Maybe i'll never need that in real life. But sometimes it's when you know that something is possible, that it gets you out of a complex situation elegantly.

    And... i like learning and experimenting new ways.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-03-19 09:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found