CSE687 - Object Oriented Design

Lecture #11 - Open/Closed Principle

Revised: 15 Feb 2009
Home Courses Code Handouts CoreTech Books Articles Math Research Masters Projects SWDev WebDev News OtherLinks SiteDesign Graduates AllPages Office Hours Notices Contents

CSE681-SWMAA CSE686-IP CSE687-OOD CSE775-DO CSE776-DP CSE778-AWP CSE784-SWS

Lecture #01 Lecture #02 Lecture #03 Lecture #04 Lecture #05 Lecture #06 Lecture #07
Lecture #08 Lecture #09 Lecture #10 Lecture #11 Lecture #12 Lecture #13 Lecture #14
Lecture #15 Lecture #16 Lecture #17 Lecture #18 Lecture #19 Lecture #20 Lecture #21
Lecture #22 Lecture #23 Lecture #24 Lecture #25 Lecture #26 Lecture #27 Lecture #28

Contents Syllabus SG - Design SG - Templates SG - Class Relationships

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

Office Hours: Instructor & TAs

Content:

This lecture presents the Open/Closed Principle, an ideal model for software development. We discuss how the C++ language can be used to build software following the principle.
  1. Syllabus
    Describes topics to be covered, reading material for you to digest before coming to class, and due dates for the assigned projects.
  2. Project #2
    Graph data type and graph algorithms.
  3. Project #2 Help
  4. The Command Pattern is an interesting application of inheritance:
    Simple Callbacks - Function Pointers
    Callbacks - Command Pattern
    Callbacks - Commands to either global and member functions
  5. Heterogeneous List Structure
    Unusual use of Liskov Substitution
  6. Open/Closed Principle
    Another fundamental OOD principle that argues for using inheritance "hooks" and template-based classes.
  7. Extensible Parsing, from Project #1
    This demonstrates the Open/Closed Principle by binding rules and actions to interfaces, used by the parser.
  8. The Adapter Pattern
    This pattern, one of about 30 we discuss in CSE776 - Design Patterns, illustrates one way to adhere to the Open/Closed Principle.
  9. Satisfying the Open/Closed Principle
    Protocols, Hooks, Policies, Inheriting Concrete Classes.
  10. Run-Time Type Indentification Presentation
    RTTI is, perhaps, the antithesis of the Open/Closed Principle. Paradoxically, I used it building the trace class.
  11. Programming to Interfaces Presentation
    Discusses interfaces, layers, factories, and breaking design, compile, and static link dependencies.
  12. Object Factory Project
    This project implements a factory that allows clients to use derived classes but only bind to their abstractions. It also demonstrates the use of products with multiple interfaces.
  13. Programming to Interface Project
    This project implements a template-based "pluggable object factory" and shows how to access members of a hierarchy through an interface.