I've been racking my brains over inheritance for a while now, but am still not completely able to get around it.
For example, the other day I was thinking about relating an Infallible Human and a Fallible Human. Let's first define the two:
The question was: IS an infallible human A fallible human OR IS a fallible human AN infallible human?
The very nice answer I received was in the form of a question (I love these since it gives me rules to answer future questions I may have).
"Can you pass an infallible human where a fallible human is expected OR can you pass a fallible human where an infallible human is expected?"
It seems apparent that you can pass an infallible human where a fallible human is expected, but not the other way around. I guess that answered my question.
However, it still feels funny saying "An infallible human is a fallible human". Does anyone else feel queasy when they say it? It almost feels as if speaking out inheritance trees is like reading out statements from propositional calculus in plain English (the if/then implication connectives don't mean the same as that in spoken English). Does anyone else feel the same?
"It seems apparent that you can pass an infallible human where a fallible human is expected, but not the other way around"
This is only a correct assumption in a certain context. Break it down this way:
If the logic of your system requires to be passed a human that will make mistakes, then this is not correct.
If the logic of the system doesn't care about what the human will do, then this is correct.
In other words it totally depends on the requirements of the system to determine the answer to the question "IS an infallible human A fallible human OR IS a fallible human AN infallible human?".
The fact that the logical objects have been anthropomorphized is probably more confusing than anything, because it seems like your confusion is stemming from a philisophical standpoint rather than a logical one. Replace "infallible human" and "fallible human" with "object X" and " object Y" and it may clear up the thinking for you.
In this case I would say a parent class is the answer: FallibleHuman inherits from Human, as does InFallibleHuman.
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