Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: OO perl query

by kirbyk (Friar)
on Nov 03, 2005 at 22:40 UTC ( #505535=note: print w/ replies, xml ) Need Help??


in reply to OO perl query

While I share some skepticism about whether you're doing things the Right Way that others have brought up, sometimes life doesn't work out that way, and you may have some need to work with legacy code. Don't _try_ to mix and match OO and functional, but if you have to be there....

One approach that works pretty well is to have a wrapper function, that can call the functional code. Like:

sub oo_generate { my $self = shift; return func_generate(@_); } sub func_generate { my ($i, $j, $and_other_bad_variable_names) = @_; ... }
This doesn't work as well if you want to do stuff with the object variables, more than pass them into functions, but it's a reasonable way to abstract something in transition. Later, if you manage to deprecate the functional subroutine, you can put all the code back into the object method without having to change the interface.

-- Kirby, WhitePages.com


Comment on Re: OO perl query
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2014-09-30 14:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (373 votes), past polls