in reply to Modification of @ISA at run time
In your particular example, what you want is a factory: a class that generates objects according to where the sun rises. For example:
# Rational helper class... package Astro::Data::Scientific; use base Solar::Data; use base Lunar::Data; # <define methods here> # "Differently rational" helper class... package Astro::Data::Mythological; use base Astrological::Data; # Pre-empt normal methods use base Astro::Data::Scientific; # <overload any methods here that the # heavens dictate should behave differently> # Factory class... package Astro::Data; # Constructor returns instances of helper classes, # depending on run-time astro[nl]o[mg]ical conditions sub new { shift; # off class name if ($sun_rises_in_west) { return Astro::Data::Mythological->new(@_); } else { return Astro::Data::Scientific->new(@_); } } # <no methods of its own, since it's never actually instantiated>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Modification of @ISA at run time
by jkeenan1 (Deacon) on Sep 01, 2005 at 12:30 UTC | |
|
Re^2: Modification of @ISA at run time
by jkeenan1 (Deacon) on Sep 02, 2005 at 04:02 UTC |