Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Liskov substitution principle
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Object-oriented programming principle}} {{Redirect|Substitutability|the economic principle|Substitute good}} {{More footnotes|date=October 2018}} [[File:Barbara Liskov MIT computer scientist 2010.jpg|alt=Portrait of Barbara Liskov|thumb|Liskov substitution was introduced by [[Barbara Liskov]]]] {{Solid principles}} The '''Liskov substitution principle''' ('''LSP''') is a particular definition of a [[subtyping]] relation, called [[behavioral subtyping|strong behavioral subtyping]], that was initially introduced by [[Barbara Liskov]] in a 1987 conference [[keynote]] address titled ''Data abstraction and hierarchy''. It is based on the concept of "substitutability" {{endash}} a principle in [[object-oriented programming]] stating that an [[Object (computer science)|object]] (such as a [[Class (computer programming)|class]]) may be replaced by a sub-object (such as a class that extends the first class) without breaking the program. It is a [[Formal semantics of programming languages|semantic]] rather than merely syntactic relation, because it intends to guarantee semantic interoperability of [[data type|types]] in a hierarchy, object types in particular. Barbara Liskov and [[Jeannette Wing]] described the principle succinctly in a 1994 paper as follows:<ref name="liskov1994">{{Cite journal|last1=Liskov|first1=Barbara|last2=Wing|first2=Jeannette|date=1994-11-01|title=A behavioral notion of subtyping|journal=ACM Transactions on Programming Languages and Systems |language=EN|volume=16|issue=6|pages=1811β41|doi=10.1145/197320.197383|s2cid=999172|doi-access=free}}</ref> <blockquote>''Subtype Requirement'': Let {{tmath|\phi(x)}} be a property provable about objects {{tmath|x}} of type {{math| T}}. Then {{tmath| \phi(y) }} should be true for objects {{tmath|y}} of type {{math| S }} where {{math| S }} is a subtype of {{math| T}}. </blockquote> Symbolically: :<math>S \leq T \to (\forall x {:} T . \phi(x) \to \forall y {:} S . \phi(y))</math> That is, if S subtypes T, what holds for T-objects holds for S-objects. In the same paper, Liskov and Wing detailed their notion of behavioral subtyping in an extension of [[Hoare logic]], which bears a certain resemblance to [[Bertrand Meyer]]'s [[design by contract]] in that it considers the interaction of subtyping with [[precondition]]s, [[postcondition]]s and [[Invariant (computer science)|invariants]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)