Web Resources:
CppReference.com, CPlusPlus.com, C++ TechLinksGoing Native 2013 - many experts
Herb Sutter's Blog, Herb Sutter on C++11, Herb Sutter keynote - Going Native 2012
Scott Meyer's Blog, S.M. on thread suspension, S.M.: C++11 Sampler
Stroustrup's Home Page, Code Project, Boost Library
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. -
Readings for this Lecture:
Class Text, CPPP:- review Chapter 7 - Classes
- read carefully Chapter 15 - Object Oriented Programming
-
Projects:
Project #1, Project1HelpS17
NoSql Database Project #2, Project2HelpS17
Parsing source code and building Dependency Relationships. Helper codes to look at:
The Project2HelpS17 folder has a FileMgr Demo and a Tree Walk Demo both of which will be useful for Project #2. DemoCurrentDirectory
Help with console processing that illustrates code language ideas and some C++11 constructs. Project #3
Code Publisher -
Several aspects of Inheritance
Using Inheritance, ppt
Discusses several distinct design uses for inheritance. The Command Pattern is an interesting application of inheritance:
Virtual Function Pointer Table structure
Diagram shows how polymorphism works. Run-Time Type Information (RTTI), ppt Class Layout demo
Shows that each object of a polymorphic class (one with virtual functions) contains a pointer to the class VfPtrTable. -
Errors using Polymorphism
hiding
Illustrates errors caused by inappropriate overloading and use of default parameters. importance of virtual destructors
Demonstrates problems caused by omission of virtual destructors. Avoiding the Dark Corners -
Vectors of Polymorphic Objects - Example Project, Structure
Shows how to use heterogeneous objects in an STL container. -
First Law of OOD
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. Heterogeneous List - polymorphism without a common base class, Heterogeneous List Structure
Unusual use of Liskov Substitution -
Functions, Function Objects, and Lambdas:
Simple Demo of Callable Objects, More Examples of callable objects I've been asked about hash functions for the STL hashed containers. I found this good reference: STL Hash Functions
-
Design Rules
Design rules and idioms that transcend Object Oriented Design. -
These are the most important items from today's lecture:
hiding
Illustrates errors caused by inappropriate overloading and use of default parameters. importance of virtual destructors
Demonstrates problems caused by omission of virtual destructors. Avoiding the Dark Corners Non-Virtual Interface Principle - a code example: see comments for explaination
Liskov Substitutibility does not demand public virtual functions.