Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Heterogenous perl modules

by TGI (Parson)
on Aug 11, 2010 at 06:02 UTC ( #854218=note: print w/replies, xml ) Need Help??

in reply to Heterogenous perl modules

You can do pretty much what you want. I have made simple modules that provided both object methods and exported functions. But I try to avoid such mixing. This practice can easily add to confusion, especially in complex systems.

I prefer to keep my OOP modules separate from my traditional, exporting modules.

If I do have a group of functions that are useful in relation to a class hierarchy, I include them in one or more collections of related utility functions. In other words, the entire module is written for normal procedural use. I also prefer to keep utility functions that are for use by the class hierarchy separate from those intended for use by consumers of the class hierarchy.

My rules of thumb for using OOP are pretty simple. If I have a group of routines that work with a data structure more than 3 levels deep, I always break it up into objects. If I have a group of functions that take the same arguments, I'll probably make an object or objects that encompasses them.

TGI says moo

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2021-05-11 16:49 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (119 votes). Check out past polls.