Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Best Practices for creating an OO version of an existing CPAN module?

by BrowserUk (Pope)
on Feb 25, 2013 at 18:20 UTC ( #1020549=note: print w/replies, xml ) Need Help??


in reply to Best Practices for creating an OO version of an existing CPAN module?

The first thing I'd ask myself is: if the module functions okay using a procedural interface; what benefit does putting an OO wrapper around it bring?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: Best Practices for creating an OO version of an existing CPAN module?

Replies are listed 'Best First'.
Re^2: Best Practices for creating an OO version of an existing CPAN module?
by topher (Scribe) on Feb 25, 2013 at 20:25 UTC

    This biggest issue comes from the use of package variables to maintain state. I have a need for the equivalent of multiple instances, and I'd rather not have to write wrapper code to continually update the package state variables every time I call a module function.

    An OO interface where I could more cleanly have multiple instances, each with it's own object state, seems like the best solution.

      This biggest issue comes from the use of package variables to maintain state.

      What module are we talking about here?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        I've been avoiding naming it because I'm really interested more in high level thoughts about process, procedure, and best practices around recreating an existing CPAN module with an OO interface, as opposed to the details of the module itself.

        I'd really like to hear more thoughts and recommendations on how to handle this in the general sense. Is it best to combine the procedural and OO interface into a single package? Or have them in separate packages? Why is one better? Or is there no real consensus on this, and no real advantage or disadvantage to either method?

        However, for the sake of completeness, the module is Net::Statsd. It uses a pair of package variables to set the destination host/port, and I have a need to for multiple separate destinations.

          This biggest issue comes from the use of package variables to maintain state. I have a need for the equivalent of multiple instances, and I'd rather not have to write wrapper code to continually update the package state variables every time I call a module function.

      Eh? What package are we talking about here and what package variables?


      Peter L. Berghold -- Unix Professional
      Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2020-02-23 08:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (102 votes). Check out past polls.

    Notices?