CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    C++ General: What are the principles of Object-Oriented Design?

    Q: What are the OOD principles and paradigms?

    A: Here is a comprehensive list of the main OOD principles with links to articles.

    Open Close Principle (OCP)
    • Description
      Software entities should be open for extension, but closed for modification.
      B. Meyer, 1988 / quoted by Robert Martin, 1996
      No significant program can be 100% closed.
      R. Martin, The Open-Closed Principle, 1996
    • Heuristics
      • Make all object-data private! No Global Variables!
      • RTTI is Ugly and Dangerous!
    • Resources


    Liskov Substitution Principle (LSP)
    • Description
      Inheritance should ensure that any property proved about super-type objects also holds for subtype objects.
      Barbara Liskov, 1987
      Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.
      Robert Martin, 1996
    • Heuristics
      • It is illegal for a derived class, to override a base-class method with a method that does nothing.
    • Resources


    Design by Contract
    • Description
      When redefining a method in a derivate class, you may only replace its precondition by a weaker one, and its post condition by a stronger one.
      B. Meyer, 1988
    • Resources


    Dependency Inversion Principle (DIP)
    • Description
      I. High-level modules should not depend on low-level modules. Both should depend on abstractions.
      II. Abstractions should not depend on details. Details should depend on abstractions.

      R. Martin, 1996
    • Heuristics
      • Design to an interface, not an implementation!
      • Avoid Transitive Dependencies
      • When in doubt, add a level of indirection
    • Resources


    The Law of Demeter (LoD)
    • Description
      Any object receiving a message in a given method must be one of a restricted set of objects.
      Strict Form: Every supplier class or object to a method must be a preferred supplier.
      Minimization Form: Minimize the number of acquaintance classes / objects of each method.

      Lieberherr and Holland
    • Resources


    Interface Segregation Principle (ISP)
    • Description
      Clients should not be forced to depend upon interfaces that they do not use.
      R. Martin, 1996
    • Resources


    Reuse/Release Equivalency Principle (REP)
    • Description
      The granule of reuse is the granule of release. Only components that are released through a tracking system can be efficiently reused.
      R. Martin, 1996
    • Resources


    The Common Reuse Principle (CRP)
    • Description
      All classes in a package [library] should be reused together. If you reuse one of the classes in the package, you reuse them all.
      R. Martin, Granularity 1996
    • Resources


    Common Closure Principle (CCP)
    • Description
      The classes in a package should be closed against the same kinds of changes.
      A change that affects a package affects all the classes in that package.

      R. Martin, 1996
    • Resources


    Acyclic Dependencies Principles (ADP)
    • Description
      The dependency structure for released component must be a Directed Acyclic Graph (DAG). There can be no cycles.
      R. Martin, 1996
    • Resources


    Stable Dependencies Principle (SDP)
    • Description
      The dependencies between components in a design should be in the direction of stability.
      A component should only depend upon components that are more stable than it is.

      R. Martin, 1996
    • Resources


    Stable Abstractions Principle (SAP)
    • Description
      The abstraction of a package should be proportional to its stability! Packages that are maximally stable should be maximally abstract. Instable packages should be concrete.
      R. Martin, 1996
    • Resources



    Q: What are other good books and articles about OOD principles?

    A: Some more good articles are listed here.
    • An Introduction to Software Architecture, David Garlan and Mary Shaw, January 1994
    • Assuring Good Style for Object Oriented Programs, Karl J. Lieberherr and Ian M. Holand
    • On the Criteria To Be Used in Decomposing Systems into Modules, D.L. Parnas
    • Design Principles, R. Martin



    Last edited by Andreas Masur; July 23rd, 2005 at 01:07 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured