UP | HOME
2015-10-15 | ../../ | Slides

Object Oriented Design Principles: SOLID, …

Table of Contents

1 Data Encapsulation v Abstraction v OOD

1.1 Encapsulation

  1. A "data structure" is declared.
  2. Certain operations are declared to be "public".
  3. The "data structure" is accessed/manipulated only via the above.

1.2 Abstraction

  1. A "data type" is declared
  2. Certain operations are available
  3. The "data type" is an abstraction
  4. Concrete representation to Abstraction mapping
  5. E.g., an array of items ==> set of items
  6. Information Hiding Principle
  7. See ../Abstraction

1.3 Class Invariants

  1. Class invariants are assertions.
  2. Must be true before and after every public methods.
  3. Must be true after every constructor.

1.4 C++/Java/… Classes

  1. Provide data encapsulation
  2. Do not do Data Abstraction
  3. Language Design
  4. public v protected v private
  5. interface v class

2 Principles of Class Design (aka SOLID)

  1. (SRP) The Single Responsibility Principle
  2. (OCP) The Open Closed Principle: Classes and methods should be open for extension (of functionality) and closed for modification.
  3. (LSP) The Liskov Substitution Principle: Subtypes must be substitutable for super type. A sub class must enhance functionality, but not reduce.
  4. (ISP) The Interface Segregation Principle
  5. (DIP) The Dependency Inversion Principle

3 Principles of Package Cohesion

  1. (REP) The Reuse Release Equivalence Principle
  2. (CCP) The Common Closure Principle
  3. (CRP) The Common Reuse Principle

4 Principles of Package Coupling

  1. (ADP) The Acyclic Dependencies Principle
  2. (SDP) The Stable Dependencies Principle
  3. (SAP) The Stable Abstractions Principle

5 Design By Contract (DoC)

6 Liskov Substitution Principle (LSP)

7 References

  1. Web site, http://www.oodesign.com Recommended Visit
  2. Bob Tarr, UMBC.edu, Some OOD Principles PDF Slides. Recommended Reading
  3. Robert Bruce Findler, Mario Latendresse, and Matthias Felleisen. Behavioral Contracts and Behavioral Subtyping. In Proceedings of ESEC/FSE-9, 229-236. http://www.ccs.neu.edu/scheme/pubs/fse01-flf.pdf 2001 Recommended Reading.
  4. Bertrand Meyer. Applying "Design by Contract". IEEE Computer, 25(10):40–51, October 1992. http://se.ethz.ch/~meyer/publications/computer/contract.pdf Also in his book "Object-Oriented Software Construction". Required Reading.

Copyright © 2015 www.wright.edu/~pmateti 2015-10-15