Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: module w/ object-oriented and functional interfaces: best practices? (2 pkgs)

by tye (Sage)
on Sep 21, 2012 at 19:56 UTC ( #994986=note: print w/ replies, xml ) Need Help??


in reply to module w/ object-oriented and functional interfaces: best practices?

Separate the methods from the procedures into different packages. I'll usually end up with the procedures being tiny wrappers around methods.

I've done the "detect if you are being called like a method or not" dance before. In hindsight, I just don't find it worth it in the long run. I always end up being burned by the relative ambiguity (calling things the wrong way or writing something new the wrong way or having to go with awkward new interfaces in order to prevent obviously unacceptable amounts of ambiguity).

Having a tiny set of wrappers in a separate package makes the situation very clear and prevents boilerplate being pasted into the top of each method-as-desert-topping-and-floor-wax sub.

- tye        

  • Comment on Re: module w/ object-oriented and functional interfaces: best practices? (2 pkgs)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (None)
    As of 2016-07-30 07:26 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      What is your favorite alternate name for a (specific) keyboard key?


















      Results (265 votes). Check out past polls.