CSE687 - Object Oriented Design
Lecture #10 - Substitution Principle
Revised: 27 February 2008
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,
Experiments with Graph implementations
-
XML Presentation
-
XMLParsing or XMLTran
Two modules that do basic XML handling - building XML strings and pulling them apart. They do not understand
XML namespaces or schemas, nor do they build a DOM. Either one will provide some parsing parts for Project #2.
-
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.
-
Traceable Project
This demonstrates the Open/Closed Principle by building a trace class that is very string-like, using
the std::string class via inheritance without modifing std::string in any way. We get an enhanced
string that knows a little about tracing program operation.
-
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.
-
Lecture #10 folder
Contains a page of links to
presentations and code discussed in this class. The Lecture folders will occasionally
hold physical files of interest as well. Usually, however, all the materials
of interest to the class are in the presentations
and code folders. The contents of these folders will grow
as you progress through the course.