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

Re: How to write effective modules

by perrin (Chancellor)
on May 04, 2009 at 04:42 UTC ( #761655=note: print w/replies, xml ) Need Help??

in reply to How to write effective modules

Is a global in the $main:: namespace the right way to do it? No, it is not! Sometimes you'll build a set of modules that all assume a certain runtime environment, but even then that environment will be encapsulated behind method calls (or at least subroutine calls), so other modules don't need to know the internals.

Basic rule of thumb: it's fine for one module to depend on the public API of another module, but it's wrong to depend on the internal implementation of that API. And $main::db wouldn't be considered a good public API by most people.

Replies are listed 'Best First'.
Re^2: How to write effective modules
by salazar (Scribe) on May 04, 2009 at 15:00 UTC
    What is an example of, and how would you go about creating, a "good" public API?
      Template-Toolkit. The pieces depend on each other, but they all have good encapsulation.
        I'm sorry to say that I've never used Template Toolkit: I am still pretty new. (err.. should I be using it?)

        Could you clarify? That'd be much appreciated.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2019-12-05 20:23 GMT
Find Nodes?
    Voting Booth?
    Strict and warnings: which comes first?

    Results (151 votes). Check out past polls.