BookRags.com Literature Guides Literature
Guides
Criticism & Essays Criticism &
Essays
Questions & Answers Questions &
Answers
Lesson Plans Lesson
Plans
My Bibliography Periodic Table U.S. Presidents Shakespeare Sonnet Shake-Up
Research Anything:        
History | Encyclopedias | Films | News | Create a Bibliography | More... Login | Register | Help
Not What You Meant?  There are 16 definitions for LSP.  Also try: Subsumption.

Liskov substitution principle

Print-Friendly
About 1 pages (295 words)

Bookmark and Share Questions on this topic? Just ask!

In object-oriented programming, the Liskov substitution principle is a particular definition of subtype that was introduced by Barbara Liskov and Jeannette Wing in a 1993 paper entitled Family Values: A Behavioral Notion of Subtyping [1]. The principle was formulated succinctly [2] as follows:

Let <math>q(x)</math> be a property provable about objects <math>x</math> of type <math>T</math>. Then <math>q(y)</math> should be true for objects <math>y</math> of type <math>S</math> where <math>S</math> is a subtype of <math>T</math>.

Thus, Liskov and Wing's notion of "subtype" is based on the notion of substitutability; that is, if S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program (e.g., correctness).

Design by contract

The Liskov substitution principle is closely related to the design by contract methodology, leading to some restrictions on how contracts can interact with inheritance:

In addition, the principle implies that no new exceptions should be thrown by methods of the subclass, except where those exceptions are themselves subtypes of exceptions thrown by the methods of the superclass. See covariance and contravariance. A function using a class hierarchy violating the principle uses a reference to a base class, yet must have knowledge of the subclasses. Such a function violates the open/closed principle because it must be modified whenever a new derivative of the base class is created.

References

  1. ^ Liskov, Barbara; Wing, Jeannette (1993-07-16). Family Values: A Behavioral Notion of Subtyping. Retrieved on 2006-10-05.
  2. ^ Liskov, Barbara; Wing, Jeannette (July 1999). Behavioral Subtyping Using Invariants and Constraints (PS). Retrieved on 2006-10-05.

View More Summaries on Liskov substitution principle
 
Ask any question on Liskov substitution principle and get it answered FAST!
Answer questions in BookRags Q&A and earn points toward
discounted or even FREE Study Guides and other BookRags products!
Learn more about BookRags Q&A
Copyrights
Liskov substitution principle from Wíkipedia. ©2006 by Wíkipedia. Licensed under the GNU Free Documentation License. View a list of authors or edit this article.

Article Navigation
Join BookRagslearn moreJoin BookRags




About BookRags | Customer Service | Report an Error | Terms of Use | Privacy Policy