Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: Short Refactoring Tip: let the object do it for you

by hardburn (Abbot)
on May 20, 2003 at 03:11 UTC ( [id://259349]=note: print w/replies, xml ) Need Help??


in reply to Re: Short Refactoring Tip: let the object do it for you
in thread Short Refactoring Tip: let the object do it for you

I'd probably work that out as a dispatch table instead:

my %STATES = ( sent => sub { . . . }, pending => sub { . . . }, waiting => sub { . . . }, procrastinating => sub { . . . }, delayed => sub { . . . }, ); # Make 'pending' and 'waiting' the same thing $STATES{pending} = $STATES{waiting}; # Later $STATES{$status->state->name}->();

It's faster than a speeding regex. And I personally think dispatch tables are sexy.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-20 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found