Lecture #12 - Dependency Inversion 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 covers Interfaces, Object Factories, and the Dependency Inversion 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 Help:

    Project #2, Project2HelpS17
    Finding file dependencies from Abstract Syntax Tree

    Project #3
    Code Publisher

    Policy for due date extensions - only for certified illness and work or interview trips out of town: one week extension, with proof.
    Only one extension per project.

  3. Principles

    Liskov Substitution Principle
    This is a fundamental OOD principle, with some surprising subtleties when using C++.

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

    The Dependency Inversion Principle
    Components should depend on abstractions, not other components.

    Classic Factory structure, Classic Factory creating polymorphic objects
    Illustrates how to create instances of a polymorphic type with clients knowing only the base class and factory interfaces.

    Object Factory Structure, 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.

    Extensible Object Factory Structure, 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.

    Programming to Interfaces Presentation
    Discusses interfaces, layers, factories, and breaking design, compile, and static link dependencies.

    Protocol-DLLDemo Project
    Demonstrates how Dynamic Link Libraries are loaded implicitly and explicitly.
    To build successfully you need to build the libraries first, then the clients.

    Interface Segregation Principle
    Another fundamental OOD principle that argues for partitioning interfaces.

  4. Reuse and the Product Model

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

    Liskov Substitution Principle
    This is a fundamental OOD principle, with some surprising subtleties when using C++.

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

    The Dependency Inversion Principle
    Components should depend on abstractions, not other components.

    Interface Segregation Principle
    Another fundamental OOD principle that argues for partitioning interfaces.

    Classic Factory structure, Classic Factory creating polymorphic objects
    Illustrates how to create instances of a polymorphic type with clients knowing only the base class and factory interfaces.

    Object Factory Structure, 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.

CST strip