Skip to main content

Object-Oriented Design Principles

Printer-friendly version

Version of 23 January 20101

In choosing design patterns and writing object-oriented code2 there are a number of design principles which have been expressed over the years by writers in the OO world. The purpose of this document is to gather together some of these principles as a reference for use by OOABL programmers. Some of these principles may seem similar or overlapping, but they are talking about different viewpoints or contexts based on the same core values. This overlap should be seen as complimentary and reinforcing rather than redundant.

Separation of Concerns (SoC)
Some might say that the core principle in OO programming is Separation of Concerns, although it is a concept which is not unique to OO. Separation of Concerns is the idea of dividing an application into distinct components that overlap in functionality as little as possible. I.e., a “concern” is a focus or responsibility and the associated attributes and behavior. Separation of Concerns is achieved by modularization and specifically through encapsulation in OO programming. Layered designs are another aspect of Separation of Concern.

SOLID Principles

The next five principles taken together are known as the SOLID principles of Object-Oriented Design3 from the first initials of their names.

Single Responsibility Principle (SRP)
One could say that the Single Responsibility Principle is the logical compliment of Separation of Concerns, i.e., that each responsibility or concern should be a separate class. A responsibility is an axis of change, so any change to the responsibility should impact only one class. No change to any other responsibility, e.g., business rules outside this responsibility, UI, database schema, report format, or other part of the system should require this class to change. Some people call this the One Responsibility Rule and express it as “A class has a single responsibility: it does it all, does it well, and does it only.4

OODesignPrinciples_20100123.pdf78.65 KB