So I just had a job interview and they gave me a list of tasks that they wanted me to work on beforehand. I finished all of the tasks except for one and was wondering if anyone could shed some light on the question.
The question went something like this
I completed tasks 1-3 but was stumped on question 4. I haven't really done much in my past work experience with inheritance and the question seemed kind of vague to me. I explained this to the employer and they seemed ok with it, but didn't tell me how it should have been done. Its been bugging me now and I'm wondering how it is done.
It sounds as though they intend you to demonstrate that you understand the limitations of simple inheritance in this exercise. You can't model Humans with both age and sex represented by inheritors in the most simple model of inheritance. Consider the following:
Abstract Class Human inherited by both Child and Adult;Abstract Class Human inherited by Male and FemaleIt becomes obvious that in this model, a human cannot be both Child and Female - or any other combination. Therefore the answer is that this simple model is inadequate and instead you should suggest alternative implementations which fulfil the requirements while using the established model as best you can.
I shall repeat what I've found myself saying often:
Objects should not attempt to represent reality. A good object model only need solve the problem at hand.
What I mean by this is that the Child/Adult and Male/Female exclusivity relationships should be modelled in the most appropriate way that solves the problem at hand. It doesn't matter if they aren't representative of reality. In your position I would attempt to suggest a variety of alternatives that would suit varying problems and explain why each is beneficial in that situation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With