in reply to Re: Re: Decision Trees and the Strategy Design Pattern
in thread Decision Trees and the Strategy Design Pattern
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.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(@_); }
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.
|
|---|