in reply to Factory classes in Perl

Making the example a bit more realistic, imagine the two types of Reindeer are in fact a *nix Reindeer and a MSWin Reindeer. You want to build the one that's compatible with the OS, but the final product should work on both the platforms transparently.

Basically, any time you write a package that instantiates different classes based on something, you should consider the factory pattern.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Factory classes in Perl
by Bod (Hermit) on Jan 11, 2021 at 22:52 UTC
    Making the example a bit more realistic

    What??? You don't have Robo-Reindeer pulling your sleigh?

    are in fact a *nix Reindeer and a MSWin Reindeer

    Ah yes!
    I totally understand when a Factory Class would be useful now. Not necessarily because of what modules are or are not installed but because of the environment in which the script might find itself with different OS, hardware, drivers or even other software...