Liskov Substitution Principle

stated by Barbara Liskov in 1988 ("Data Abstraction and Hierarchy", SIGPLAN Notices, 23 May, 1988),

states that a subclass should always be usable in place of its superclass without affecting callers.

This principle protects the concept of concrete inheritance.

For example, a Dog object should be usable wherever an Animal has to be used. Subclasses that violate the Liskov Substitution Principle are also unfriendly to unit testing. A class without concrete method overrides should pass all the unit tests of its superclasses.

posted @ 2012-01-16 10:39  万法自然~  阅读(142)  评论(0编辑  收藏  举报