Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The thing is, at some point you're going to have to code the 'what happens next' process. It may make sense though to add a do_next_thing method to your state class and then write:
sub TicketState::New::next_action { 'send_ticket_to_supervisor' } sub TicketState::Pending::next_action { 'send_to_editorial_group' } sub TicketState::do_next_thing { my $self = shift; my $action = $self->next_action; $self->$action(@_); }
By doing things this way you get to give meaningful names to the individual actions handled by a state, but still have a simple dispatch system that simply calls $ticket->do_next_action on every ticket it dispatches.

If you're using the state simply to control the flow of an object through a system and you've not got other state dependent behaviour then you can probably get away with having a single state class and a handy dandy config file but I don't think I'd recommend starting out with one.


In reply to Re: Re: Re: Decision Trees and the Strategy Design Pattern by pdcawley
in thread Decision Trees and the Strategy Design Pattern by djantzen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-19 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found