Le changement de visibilité d'une fonction virtuelle est-il un viol du LSP ?
Le problème c'est que deux principes quelque peu différents ont été présentés ici:
La première version caractérise une relation de sous typage alors que la seconde pose cette relation comme condition préalable.
Citation:
"If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T"
-- BarbaraLiskov, Data Abstraction and Hierarchy, SIGPLAN Notices, 23,5 (May, 1988)
La seconde formulation est la plus pertinente puisqu'on s'interesse au changement de visibilité de fonction virtuelle (la relation de sous typage est acquise).
Citation:
"Let q(x) be a property provable about objects x of type T. Then q(y) should be true for objects y of type S where S is a subtype of T"-- Liskov and Jeannette Wing, 1994 paper