CSC/ECE 517 Fall 2011/ch6 6b mm: Difference between revisions
Line 9: | Line 9: | ||
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states: | Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states: | ||
<blockquote>If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).</blockquote> | <blockquote>If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).<ref>Wikipedia</ref></blockquote> | ||
==References== | ==References== |
Revision as of 05:45, 15 November 2011
Subclassing
Introduction
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program.
Liskov Substitution Principle
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:
If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).<ref>Wikipedia</ref>
References
Liskov Substitution Principle. Wikipedia