General information
Category:
Object Oriented Programming
>Also the use of a consistent interface is helpful, in your traffic example, when there may be more than one driver class to control the automobiles. perhaps you need a taxi driver, a teenage driver, a race car driver etc.
Absolutely. If the app needed to model drivers, then it should do so. Only the app can decide; this can't be determined a priori.
For example, a programming project at school was to create a simulation of computer lab use. The objects were students, computers and TAs. A more detailed simulation could have also modelled class schedules, bed times, midterm times, etc. Since you can't model the entire world (even if it would make the model more accurate), you have to decide based on the needs of the application.
>If each one had to talk to its vehicle in a different way then you would preclude any kind of generic code in the driver classes because there was no consistent interface to the vehicles.
Actually, the example I gave used the option with the generic Move method.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only