Lecture overview -- Keyboard shortcut: 'u'  Previous page: Specialization of classes -- Keyboard shortcut: 'p'  Next page: Extension of Classes [Section] -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 8 : 40
Object-oriented Programming in C#
Specialization, Extension, and Inheritance
The Principle of Substitution

When specialization is used in pure form the principle of substitution applies

The class B is a specialization of class A

If B is a subclass of A, it is possible to substitute an given instance of B in place of an instance of A without observable effect

  • Concrete example:

    • It is possible to replace a BankAccount with a CheckAccount

    • It is not, in general, possible to replace a CheckAccount with a BankAccount