Lisksov Substitution Principle

    內容表格
    沒有標頭

    LSP(Lisksov Substitution Principle)說明了OOP中繼承原則的適用性, 其適用性即保持良好的擴展與靈活度. LSP原則主要有兩種規格定義:

    1. If for each object to 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.
      如果對每一個型別為S的物件o1, 都有型別為T的物件o2, 使得以T定義的所有程式p在所有的物件o1都替換成o2時, 程式P的行為沒有發生變化, 那麼型別S就是行別T的子型別.
    2. Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.
      所有參照基礎類別的地方必須能透明地使用其衍生類別的物件.
    標籤 (Edit tags)
    • No tags
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core