Lecture #20 - Interface Segregation 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 and the Interface Segregation 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. Projects:

    Project #3, Project3HelpS17 Code Publisher Samples
    Code Publisher - publishing source code files as web pages.

    Project #4, Project4HelpS17
    Remote Code Publisher
  3. Components:

    A Component is code focused on one particular activity, accessed only through an interface and an object factory, and implemented as a dynamic link library. You can find more detail about components here.

    ComponentRefCount:
    Components are often shared, using reference counting to destroy the components when all users have finished. You can implement reference counting with std::shared_ptr. If you want to build reference counting into the component you may use this ComponentRefCount package as an example.

    Singleton:
    Singletons provide global access to a shared instance of some type. The Singleton template class provides this in a reference counted implementation.

  4. 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.

    MakeDLL Structure, MakeDLL: Dynamic Link Library Project
    This project demonstrates that compile and static link dependencies can be broken by programming to interfaces and using object factories.

    DLL_ProtocolDemo Project
    Demonstrates how Dynamic Link Libraries are loaded implicitly and explicitly.

    Interface Segregation Principle
    Discusses why you may need to provide more than one interface for a component.
  5. Invocations Revisited - added more capture examples
  6. Run-Time Type Indentification Presentation
    RTTI is, perhaps, the antithesis of the Open/Closed Principle. Paradoxically, I used it building the trace class.
  7. Exceptions Presentation
  8. Basic Exceptions Demo
  9. Standard Exceptions Demo
  10. Exception Performance Demo
  11. Thinking about Software Design:

    Software Design
    Broad survey of ideas with examples
    Design Presentation
    Summarizes design issues for modules and classes.
    Design Guidelines
    Design rules and idioms that transcend Object Oriented Design.

    Design Summary

CST strip