Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Superclass vs. Subclass structures
Message
From
29/10/1998 00:34:12
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00151975
Message ID:
00152117
Views:
20
>>John,
>> I would choose 4. The vehicle class is way too generic for the three subclasses. And if you further subclass the airplane,rowboat, and car classes those classes will have very little use for the vehicle superclass. So the Vehicle Superclass becomes nothing more than wasted resources. You end up with an object that's taking up more resources than it needs. On the other hand if you had the Vehicle Superclass you could overload the + operator and then
>>airplane + rowboat = airboat. What do you think?
>>
>Mark,
>
>Just a couple of questions;
>
>Do the vehicles not all share;
>
>1) a capacity
>2) the ability to move
>3) a maximum range for movement
>4) a maximum speed of movement
>5) a preparation for movement
>6) requirements for maintenance
>7) etc etc etc
>
>Would not every subclass of airplane also share all those properties and methods? Would not all automobilies also share all those things as well?
>
>The use of a vehicle superclass allows you to define the common properties and methods for all vehicles in one place and then use the subclasses to specfiy the descrete details of a certain vehicle. It is not unreasonable to imagine a Vehicle class with subclass ariplane whihc in trun has subclasses of 737, 757, 767, 777, etc. each with its own details but all sharing in the common data and behavior of both Airplane and Vehicle.
>
>You could then write code that told a vehicle to move to a certain place and never need to chane that code if the vehicle in question changed from a boat to a 757. The 757 would just get there faster and it would likely follow a different route.

Jim,
I see that my overloaded operator joke didn't go over so well, better stick with programming. I agree with you about the properties, initially I had a problem with creating a superclass with skeletal members and variables. The funny thing is that with the properties that you stated that they could also describe a horse or camel and that's when it hit me the point of creating the superclass vehicle. Thanks for the refresh of OO.

Mark
Previous
Reply
Map
View

Click here to load this message in the networking platform