Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Perl Modules with 2 or more classes

by choroba (Bishop)
on Oct 19, 2011 at 10:50 UTC ( #932356=note: print w/replies, xml ) Need Help??

in reply to Perl Modules with 2 or more classes

You can add more package declarations to a file, but you can only use the one that has the name corresponding to the file name (and it will load all the remaining packages in the same file).
  • Comment on Re: Perl Modules with 2 or more classes

Replies are listed 'Best First'.
Re^2: Perl Modules with 2 or more classes
by armstd (Friar) on Oct 20, 2011 at 04:39 UTC

    This is actually something I've always found frustrating about OOP. To be fair, it's not like any other language really has any better solution, and Python's answer seems to be even worse, while pretending to be better somehow.

    I'm a big fan of compilation-on-demand. So I want my callers to 'use' as little as possible. That means 'use'ing very specific subclasses. That means they must exist in unique files.

    Unique files are good for maintainability, contrary to Python credo. Files/classes that have old, old mtimes are by definition "stable". It can be trivially proven that they have not changed. Additionally, multiple files helps avoid merge conflicts for parallel team development. Split the responsibility of the developers on the team, and split the responsibility of the classes/files they are working on accordingly. Good design scales maintainability as well.

    OTOH, I'm also a big fan of ease-of-use. Why do I have to 'use DBD::blah'? I don't call anything in there... DBI does. Why doesn't DBI 'use' it for me instead? Having one core module to rule all the others is a good thing. But then you don't really know for sure what's getting brought in and when... so debugging is more complicated.

    I digress... just things worth thinking about...


      Why do I have to 'use DBD::blah'? I don't call anything in there... DBI does. Why doesn't DBI 'use' it for me instead?

      Huh? You don't need to use DBD::blah, just do DBI->connect('dbi:blah:FooBarDB') and it will do what you're asking for. You basically only need to use DBD modules to import extra things they might provide, like use DBD::Oracle qw/:ora_types/; for Oracle-specific data types.

      Maybe you were asking rhetorically to make a point?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://932356]
[Corion]: :) I had to reconnect my DVD drive to actually burn the CD-R - I think I last spun it up three years ago or something...
Discipulus must burn phot cd to send to mother in law..
[Corion]: I wonder, maybe the time is right to offer a CD burn service - you send the files, I burn them onto CD-R and mail it to whoever you specified. A printed CD costs extra ;)
[Corion]: Just because there are things that you can't do/share via Facebook. Or even better, you mail me the iPhoto / Facebook page and I create and mail a Photo CD from them ;)

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2017-11-20 18:45 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (291 votes). Check out past polls.