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

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

by tye (Cardinal)
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 exploiting the Monastery: (6)
As of 2014-07-13 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (249 votes), past polls