Free Republic
Browse · Search
News/Activism
Topics · Post Article

To: antiRepublicrat
Being derived from Vehicle, it is a Vehicle. OOP 101.

OOP does not work in the real world. Taxis are not derived from Vehicle, they are a Vehicle. OOP is conceptual - Taxis are not.

794 posted on 03/16/2005 8:27:48 AM PST by Last Visible Dog
[ Post Reply | Private Reply | To 785 | View Replies ]


To: Last Visible Dog
Taxis are not derived from Vehicle, they are a Vehicle. OOP is conceptual - Taxis are not.

In a taxi company management application, an object of the the Taxi class would be representing a physical taxi. Duh.

Guess what, in the application here we have a Person class to represent people, and a (believe it or not) Vehicle class to represent vehicles. In our case we don't extend Vehicle because we only need a small set of information that's generalized to all vehicles on the road, like what model it is. However, if we were told to specifically track, say, government-owned vehicles, we would extend the Vehicle class to handle all the extra information and processes associated with a government-owned vehicle.

So you would make a Vehicle class that had loads of properties and methods not used in most of the instantiated objects of class Vehicle. A motorcycle is going to have an unused method "RaiseBed" because you put that into Vehicle to handle dump trucks. Just unbelievable.

If you are indeed employed as a programmer, do not let your employer see your posts if you value your job.

812 posted on 03/16/2005 9:56:15 AM PST by antiRepublicrat
[ Post Reply | Private Reply | To 794 | View Replies ]

Free Republic
Browse · Search
News/Activism
Topics · Post Article


FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson