Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Superclass vs. Subclass structures
Message
 
À
28/10/1998 17:15:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00151975
Message ID:
00152181
Vues:
24
Hi John,

... and I think that if there is no need for the Vehicle class, the best path is not to introduce it.

I.o.w. if "move" is the only thing that Vehicles do, and if "vehicleness" is never used, or to be used, then you are "polymorphing" without reason with your nr 2. Your nr 4 will allow more flexibility.

And the fact that you wonder about this makes me think that 4 is ok.

My 2 BEF.

Marc




>Hi boys & girls ---
>
>Another design abstract problem. Let us say that we have a class called Airplane that's parent class is Vehicle. All Vehicles derived classes Move. How they move is quite different: Airplanes fly, Cars drive, and Rowboats are rowed. Which of the four approaches are taken:
>
>1) The Vehicle superclass has Fly,Drive,and Row methods. The implementation of these methods is at either superclass or class level.
>
>2) The Vehicle supports a Move method. The subclass defines Move as appropriate and returns a value indicating it flew,drove, or was rowed.
>
>3) The subclasses have Fly, Drive, and Row methods as apppropriate; no Move or move specific methods are defined in the Vehicle superclass.
>
>4) We have *no* Vehicle superclass and each subclass of Airplane, Rowboat, and Car is it's own superclass.
>
>I currently strive for option 2 and used to use 4. Comments?

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform