CSE687 - Object Oriented Design
Lecture #10 - Substitution Principle
Revised: 17 February 2009
Web Resources:
Stroustrup's Home Page,
Assoc. of C/C++ Users,
C++ at Microsoft,
Code Project,
Sells Brothers,
Guru of the Week,
C/C++ User's Journal,
devCentral,
Dr. Dobb's Journal,
Boost Library,
techNetCast
Content:
This lecture covers the Liskov Substitution Principle and its powerful applications in design. Polymorphism follows
directly from Liskov Substitutability and helps us build loosely coupled systems.
-
Syllabus
Describes topics to be covered,
reading material for you to digest before coming to class, and due dates
for the assigned projects.
-
Project #2
-
Project #2 Help,
Help with Graph implementations
-
Class Layout demo
-
Using Inheritance
Discusses several distinct design uses for inheritance.
-
The Command Pattern is an interesting application of inheritance:
Simple Callbacks - Function Pointers
Callbacks - Command Pattern
Callbacks - Commands to either global and member functions
-
Virtual Function Pointer Table structure
-
hiding
Illustrates errors caused by inappropriate overloading and use of default parameters.
-
importance of virtual destructors
Demonstrates problems caused by omission of virtual destructors.
-
Vectors of Polymorphic Objects - Example Project
Shows how to use heterogeneous objects in an STL container.
-
Liskov Substitution Principle
This is a fundamental OOD principle, with some surprising subtleties when using C++ (see example project below).
-
Non-Virtual Interface Principle - a code example: see comments for explaination
Liskov Substitutibility does not demand public virtual functions.
-
C++ Casts
-
Design Rules
Design rules and idioms that transcend Object Oriented Design.