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 | |
by perrin (Chancellor) on May 04, 2009 at 15:53 UTC | |
by salazar (Scribe) on May 04, 2009 at 17:05 UTC | |
by perrin (Chancellor) on May 04, 2009 at 19:39 UTC |
In Section
Seekers of Perl Wisdom