in reply to packages (Classes) and file names

Memory is coming back. The LDAP, DB, ... code belongs into subclasses, and the Users class has to figure out and die if some needed methods are not implemented in the required subclass. Sorry folks, but here you can see what two years without programming (perl) does to an average brain.

Maybe it's time to go to urinate at the chestnut. The circus is approaching. My dog is calling me out.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^2: packages (Classes) and file names
by clscott (Friar) on Mar 02, 2023 at 14:55 UTC
    An alternate approach to to do it this way:
    • User::Base <- base class that implements the default methods
    • User::{DB,LDAP,...} <- inherit from User::Base and provide specific implementations
    • User <- Factory class that inspects the details and returns the right class
    my $user = User->new( system => 'LDAP' , ...); # $user isa User::LDAP
    --
    Clayton