OO Design Principles

OOD (Object Oriented Design) is a process of planning a system of interaction object for the purpose of solving software problems. It is a one type of Software Design.

SOLID Principle:

  • SOLID is a mnemonic acronym for five different OOD principles intended to make software design more understandable, flexible and maintainable.

  • Combining this five principles, it makes easy for the programmer to develop a software that are easy to maintain and extend.

  • It makes easy to avoid code smells and easy code refractor.

S - Single-responsibility

A class should have one and only one reason to change, states that a class should have only one job.

O - Open-Closed

Objects or entities should be open for extend and closed for modification. It means that, class should be easily extendable instead of modifying the class directly.

L - Liskov Substitution

It states that every subclasses/derived classes should be substitutable for their base/parent class.

I - Interface Segregation

A client should never be forced to implement an interface that it doesn't use or clients shouldn't be forced to depend on methods they do not use.

EX: Creating a single interface for multiple objects, create different interfaces based on their requirements.

D - Dependency Inversion

Entities must depend on abstractions not on concretions. It states that the high level module must not depend on the low level module, but they should depend on abstractions.

DRY Principle:

  • DRY - Don't repeat yourself is a software development principle aimed at reducing the repetition of software patterns. It is replaceable, to avoid redundancy with abstraction or using data normalization.

  • This principle is stated as Every piece of knowledge must have a single, clear-cut, authoritative responsibility within a system.

  • When the DRY principle is applied successfully, a modification of any single element of a system does not require a change in other logically unrelated elements. Additionally, elements that are logically related all change predictably and uniformly, and are thus kept in sync.

Other principles:

KISS - "Keep it simple, silly", "keep it short and simple", "keep it simple and straightforward", "keep it small and simple", or "keep it stupid simple".

GRASP - General Responsibility Assignment Software Patterns.

IDEF4 - Integrated DEFinition for Object-Oriented Design - design of component-based client/server systems.

Last updated