shmem has asked for the wisdom of the Perl Monks concerning the following question:
Surely this has been handled long ago and far away. Maybe I didn't notice, maybe I forgot, I am getting old.
So, is it bad practice to have multiple packages at different paths implementing the same methods according to the configuration of the requiring package?
Say, I have some application which needs auth methods, search and such and can be configured to either use some X500 implementation (e.g. LDAP, AD) or database stuff. Is it sensible to
if($config{X500}) { require Users::LDAP; } elsif ($config{DB}) { require Users::DB; } elsif (...) { ... } else { die "no suitable User handling module found\n"; }
and have Users/{LDAP,DB,...}.pm which all implement Users via package Users; ?
Which each sport:
package Users;
Well, I could have a "Users" package which gets the configuration object passed in upon import and does what it should. What do you think is best? Glove this or that way turned in or out?
Well yes, polymorphism, signatures and such... how would you handle that case?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: packages (Classes) and file names
by Fletch (Bishop) on Mar 02, 2023 at 17:16 UTC | |
Re: packages (Classes) and file names
by NERDVANA (Priest) on Mar 02, 2023 at 15:22 UTC | |
Re: packages (Classes) and file names
by shmem (Chancellor) on Mar 01, 2023 at 22:58 UTC | |
by clscott (Friar) on Mar 02, 2023 at 14:55 UTC | |
Re: packages (Classes) and file names
by BillKSmith (Monsignor) on Mar 03, 2023 at 14:05 UTC | |
by karlgoethebier (Abbot) on Mar 03, 2023 at 19:07 UTC | |
by BillKSmith (Monsignor) on Mar 03, 2023 at 19:36 UTC |