OO Design
This page contains basic principles of Object-Oriented design.
Basic Characteristics / Pillars
Basic Characteristics / Pillars
There are three pillars of object-oriented programming. These are
- Encapsulation: a language mechanism that allows bundling related data with the operations, and restricting access to some object's components.
- at Wikipedia (link)
- Inheritance: a way to reuse code from another, inherited, object.
- Polymorphism: ability to create a variable, a function, or an object that has more than one form.
Object-Oriented Design Principles
Object-Oriented Design Principles
Related topics include Design Patterns and Coding Standards.
One of the main OO principles is high cohesion and low coupling.
General OO design principles:
- Single Responsibility Principle (SRP): A class should have only one reason to change.
Dependency Management, using the following Object-Oriented design principles:
- The Open Closed Principle (OCP): A module should be open for extension but closed for modification.
- The Liskov Substitution Principle (LSP): Subclasses should be substitutable for their base classes.
- The Dependency Inversion Principle (DIP): Depend upon Abstractions. Do not depend upon concretions.
- The Interface Segregation Principle (ISP): Many client specific interfaces are better than one general purpose interface.
Principles of Package Architecture, with Package Cohesion Principles
- The Release Reuse Equivalency Principle: The granule of reuse is the granule of release.
- The Common Closure Principle: Classes that change together, belong together.
- The Common Reuse Principle: Classes that aren't reused together should not be grouped together.
The Package Coupling Principles
- The Acyclic Dependencies Principle: The dependencies between packages must not form cycles.
- The Stable Dependencies Principle: Depend in the direction of stability.
- The Stable Abstractions Principle: Stable packages should be abstract packages.
References
References
- Robert C. Martin, www.objectmentor.com, Design Principles and Design Patterns text (link). Copy attached to this page.
- Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship
- Robert C. Martin, Agile Principles, Patterns, and Practices in C#
Links
Links
- Refactoring, site, by Martin Fowler (link)