Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Importing constants into another module

by djantzen (Priest)
on Feb 03, 2005 at 02:30 UTC ( #427504=note: print w/replies, xml ) Need Help??


in reply to Importing constants into another module

What's the benefit of exporting these constants? Just call them with the package name prepended like Audit::Config->HOST_BIN. It's more verbose, but it's better OO for reasons of encapsulation, it simplifies your code because you don't have to twiddle with exports, and it advertises to readers of the code exactly where that data is coming from and thereby increases maintainability.


"The dead do not recognize context" -- Kai, Lexx

Replies are listed 'Best First'.
Re^2: Importing constants into another module
by paulski (Beadle) on Feb 03, 2005 at 02:47 UTC
    You're right, it's a tradeoff. I could either have more verbose constants, which would clutter up the code (they're used very frequently) and good OO design. Or I could export them all so other modules looks less cluttered but sacrifice maintainability/extensibility in the future.

    Given that this application has a limited lifespan and scope, I'm thinking the latter makes the most sense.

    Feel free to call me insane. :-)

      Thanks for everyone's help. I've got this module stuff down now. :-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2020-06-02 05:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (13 votes). Check out past polls.

    Notices?