FACTOID # 67: Nearly a quarter of people in Monaco are over 65.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

FACTS & STATISTICS    Simple view

  1. Select countries to view: (hold down Control key and click to select several)

     

     

    Compare:

     

     

  1. Select fact or statistic: (* = graphable)

     

     

     

  2. (OPTIONAL) Compare to statistic: (both need to be graphable)

     

     

     

  3. View result as:

     

       
(OR) SEARCH ALL encyclopedia, stats & forums:   

Encyclopedia > Liskov substitution principle

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]. (It is not the only definition; see datatype.) In computer science, object-oriented programming is a computer programming paradigm. ... ... Barbara Liskov (born November 7, 1939) is a prominent computer scientist. ... In computer science, a datatype or data type (often simply a type) is a name or label for a set of values and some operations which one can perform on that set of values. ...


The principle was formulated succinctly [2] as follows:

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.

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). Substitutability is a principle in computer programming. ... In theoretical computer science, correctness of an algorithm is asserted when it is said that the algorithm is correct with respect to a specification. ...

[edit]

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: Design by contract, DBC or Programming by contract is a methodology for designing computer software. ... In object-oriented programming, inheritance is a way to form new classes (instances of which are called objects) using classes that have already been defined. ...

  • Preconditions cannot be strengthened in a subclass. This means that you cannot have a subclass that has stronger preconditions than its superclass.
  • Postconditions cannot be weakened in a subclass. This means that you cannot have a subclass that has weaker postconditions than its superclass.

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. In logic a precondition is a condition that has to be met, before a main argument can have any value. ... A postcondition is a fact that must always be true just after the execution of some section of code. ... As used in computer science, in particular in object oriented programming: Covariance means that the type of arguments, return values, or exceptions of overriding methods can be subtypes of the original types. ...


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. In object-oriented programming, the open/closed principle states that a class must be both open and closed, where open means it has the ability to be extended and closed means it cannot be modified other than by extension. ...

[edit]

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.

  Results from FactBites:
 
What does Barbara Liskov have to say about Equality in Java? (3919 words)
captures physical equality, which ignores the Liskov Substitution Principle, one of the fundamental principles in OO design.
The whole LSP thing in Java is interesting.
That is: According to the LSP, if C2 is a subclass of C1 and D2 is a subclass of D1, and there's a method in D1 that returns an object of class C2, then a method with the same name in D2 can return an object of class C1.
Liskov substitution principle - Wikipedia, the free encyclopedia (296 words)
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).
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.
Such a function violates the open/closed principle because it must be modified whenever a new derivative of the base class is created.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.