>Len,
>
>> Christopher:
>>
>> CS:
>>>While I can quite understand the short-term convenience of it,
>>>my problem with method overriding is that it torpedoes the
>>>Liskov Substitution Principle: an instance of a subclass is
>>>no longer guaranteed to be an instance of the baseclass.
>>>That's more than just a bizarre abuse -- it's an overthrow of
>>>polymorphism as well as inheritance.
>>
>> I don't agree. Identity and behavior are orthogonal aspects in
>> OO.
>
>Not so. If an instance X of class A is defined as necessarily
>having behavior P, but a programmer now states that entity X in
>this situation must now have behavior Q but not P, then, for all
>I know, X is no longer an A. (01)
LSP does not relate identity to behavior. In fact it does not deal with
identity or behavior directly - instead it promotes substitutability and
correctness resulting from behavior.
(see http://en.wikipedia.org/wiki/Liskov_substitution_principle) (02)
I can understand your concern about method overriding done incorrectly in
violation of LSP, but that does not mean that allowing overriding "torpedoes
LSP". OO languages such as Java provide type-safety of overriding, which
guaranties invariance of type properties resulting from it. (03)
Yes, programmer can still violate LSP, the same way he/she can violate other
properties at runtime. I doubt, that this can be prevented with any language or
system. You can go to next level with proof-carrying code, but it only
guaranties some properties of program at runtime - not consistent behavior. (04)
More generally, I don't believe that identity or behavior of an entity can be
guarantied in absolute sense, and even less that it can be feasible to
implement such checks outside basic finite automation. So the question for me
is: what properties should constitute identity and behavior and what is the
reasonable scope to enforce it. (05)
_________________________________________________________________
Message Archives: http://ontolog.cim3.net/forum/ontolog-forum/
Subscribe/Config: http://ontolog.cim3.net/mailman/listinfo/ontolog-forum/
Unsubscribe: mailto:ontolog-forum-leave@xxxxxxxxxxxxxxxx
Shared Files: http://ontolog.cim3.net/file/
Community Wiki: http://ontolog.cim3.net/wiki/
To Post: mailto:ontolog-forum@xxxxxxxxxxxxxxxx (06)
|