Type Substitution / Software Design Help

Soldato
Joined
7 Apr 2004
Posts
4,212
Hi,

I'm trying to revise for a uni software engineering exam in a couple of weeks, and im having some problems understanding type substitution.

Here is a question from a past exam paper:Click

Now, I hate this exam because of the vagueness between answers, there are multiple correct ones and we have to pick the 'best' answer, in this case i think the best one is A, while D is correct it isn't a reason for 'good design'.

What i don't understand is how (in the case of D) a child class can be substituted for its parent class type, when by definition a child class implements additional functionality to its parent class. So how can you substitute a child type into a parent type which doesn't understand half of its functionality? Maybe im thinking about this incorrectly in which case i hope someone can point me towards the right direction. Is this what strong typing is? :confused:

Thanks for any help
Jack
 
Brilliant, thanks very much. Polymorphism was on my to learn list for another exam anyway, would have helped if i had learnt it properly before this stuff, but i think that makes sense now.

Thanks a lot for the help
 
Thanks again for all the help, i completly agree with it being a confusing question, hell its a confusing exam and isnt gonna be easy to pass :(
 
Back
Top Bottom