On Mon, Jun 25, 2001 at 12:05:42PM -0700, Peter Scott wrote:
> >In Perl5 I am forced to create 4 new classes:
> >Employed_Male, Employed_Female, Unemployed_Male,
> >Unemployed_Female. The combinatorial explosion can,
> >well, explode!
>
> What's wrong with multiple inheritance?
You get a maze of twisty subclasses, all slightly different. And
every time you add a new type they all have to change. Consider what
happens if you added a new Person subclass, 'Other'. Now you need
Employed_Male, Employed_Female, Employed_Other, Unemployed_Male,
Unemployed_Female, Unemployed_Other. You can see how this will
rapidly get nasty.
Of course, you *could* write Employee as a factory, generating the
necessary subclasses on the fly and blessing the new object into them
as needed...
package Employee;
foreach my $sex (qw(Male Female Other)) {
@{'Employee::'.$sex.'::ISA'} = qw(Employee $sex);
}
but delegation is probably the way to go.
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl6 Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
<purl> Hey, Schwern! THERE IS A HUGE GAZORGANSPLATTEDFARTMONGERING-
LIGHTENINGBEASTASAURSOPOD BEHIND YOU! RUN, BEFORE IT GAFLUMMOXES YOUR
INNARDLYBITS!