Lecture #11 - Open/Closed Principle

Web Resources:

CppReference.com, CPlusPlus.com, C++ TechLinks
Going 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 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. Readings for this Lecture:

    Class Text, CPPP:
    • review Chapter 15 - Object Oriented Programming, Chapter 16 - Templates
  3. Projects:

    Project #2 , Project2HelpS17, Tree Walk Demo
    Parsing with Abstract Syntax Tree container

    Project #3
    Code Publisher

  4. new style casts demo, const pointers demo
  5. Callable Objects:

    Simple Demo of Callable Objects, Callable Objects Examples
    Illustrates use of functions, function pointers, std::function<R(A...)>, lambdas, and lamda closures.
  6. Applications of Inheritance

    The Command Pattern is an interesting application of inheritance:
  7. Open/Closed Principle

    Open/Closed Principle
    Another fundamental OOD principle that argues for using inheritance "hooks" and template-based classes.

    Extensible Parsing, from Project #2, Blog on Parser
    This demonstrates the Open/Closed Principle by binding rules and actions to interfaces, used by the parser.

    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.

    Heterogeneous List Structure
    Unusual use of Liskov Substitution

    Satisfying the Open/Closed Principle
    Protocols, Hooks, Policies, Inheriting Concrete Classes.

  8. Run-Time Type Indentification Presentation
    RTTI is, perhaps, the antithesis of the Open/Closed Principle. Paradoxically, I used it building the trace class.
  9. Exceptions
  10. Exception demo
  11. Enforcements
  12. Software Design
  13. Design Presentation
    Summarizes design issues for modules and classes.
  14. Design Guidelines
    Design rules and idioms that transcend Object Oriented Design.
  15. Design Summary
    Design rules and idioms that transcend Object Oriented Design.
  16. These are the most important items from today's lecture:

    Callable Objects
    Illustrates use of functions, function pointers, std::function<R(A...)>, lambdas, and lamda closures.

    Open/Closed Principle
    Another fundamental OOD principle that argues for using inheritance "hooks" and template-based classes.

    Extensible Parsing, from Project #1, Blog on Parser
    This demonstrates the Open/Closed Principle by binding rules and actions to interfaces, used by the parser.

CST strip