wve

导航

里氏替换原则

Liskov Subsitution Principle, LSP :

  •   If for object o1 of type S there is an abject o2 of type T such that for all programs P defined in terms of T,

the behavior of P is unchanged when o1 is subsituted for o2 then S is a subtype  of  T.

  •   Functions that use pointers or reference to base classes must be able to use objects of derived classes without 

knowing it.

  1.   子类必须完全实现父类的方法
  2.   子类可以有自己的个性
  3.   覆盖或实现父类的方法时输入参数可以被放大
  4.   覆写或实现父类的方法时输出结果可以被缩小

posted on 2012-07-30 10:22  wve  阅读(119)  评论(0)    收藏  举报