in reply to Stuck on packages

One thing I want to point out. Generally, inheritance is used for "ISA" relationships (which is why Perl uses the "@ISA" array to declare inheritance). Where type A "IS A" type B. In your case, you sound like you want to say Family IS A Private which IS A Car. But that doesn't make sense: families are not cars! Families have cars, but are not cars themselves.

Perhaps you meant that it was a FamilyCar. Or a Car::Family. Those would both say you're dealing with a specific type of car - the family car. (More commonly known as a sedan, I think). Names of your packages are important. They form part of your code-as-documentation. If you had the above code working the way you wanted, and then 12 months from now you came back as an OOP guru to fix something, you'd probably be confused. While that is normal when going from beginner to advanced, I'm hoping you can learn how important names are at the same time as you're learning the implementation details of OOP in Perl. This concept, however, is not Perl-specific. It applies no matter what language you're doing OOP in. Or procedural programming. Or functional programming. Names are always important.

Replies are listed 'Best First'.
Re^2: Stuck on packages
by GrandFather (Saint) on Jan 04, 2007 at 20:09 UTC

    We have had sedans, station wagons and vans as family "cars". Perhaps what he needs is either multiple inheritance or a property to describe how the vehicle is used?

    Our current family sedan has a two tone colour scheme so rather than a colour property as a scalar, maybe a ColourScheme object as a property or mixin would be appropriate?


    DWIM is Perl's answer to Gödel