CSC/ECE 517 Fall 2011/ch6 6b mm: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<p style="font-size: 24px">'''Subclassing'''</p> | <p style="font-size: 24px">'''Subclassing'''</p> | ||
== | ==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: | |||
<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> | |||
== | ==References== | ||
[http://en.wikipedia.org/wiki/Liskov_substitution_principle Liskov Substitution Principle] Wikipedia | |||
===Citation Notes=== | ===Citation Notes=== | ||
===Full References=== | ===Full References=== | ||
http://en.wikipedia.org/wiki/Liskov_substitution_principle | |||
===External Links=== | ===External Links=== |
Revision as of 05:42, 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.).
References
Liskov Substitution Principle Wikipedia
Citation Notes
Full References
http://en.wikipedia.org/wiki/Liskov_substitution_principle