2 ms·
... it was a roundabout way of explaining how right you were, or at least in my initial reading of it. I see thing which is called a Car, an instance of which
by drone 14y ago
... it was a roundabout way of explaining how right you were, or at least in my initial reading of it.
I see thing which is called a Car, an instance of which is stored in the Model, which may contain other things, including other types of Transports. The user interacts with the View, instructing a left turn - the controller grabs the Car (why it grabs the Car, and not the Bike is undefined =), and tells it to turn left. None of the M, V, or C understand what a left turn is - but the controller knows that the Car can perform such a thing if instructed. The Controller knows it can tell the Car to turn, because the Car is descended from a Transport, and all Transports have a virtual method for turning.
That last sentence was in my head and unfortunately took over my comment.
- alttab 14y agoAh I understand. Yes polymorphism in this case would hide the details, and the implementation for turning the car belongs inside of that object.