5 SOLID Principles of Object Oriented Design-A Summary

A summary of 5 SOLID Principles of Object Oriented Design

Mar 21, 2024code
blog
Two black flat screen computer monitors PC: Fotis Fotopoulos, Unsplash

Introduction

The SOLID design principles is a set of guidelines aimed at helping software developers create robust, maintainable and extensible object-oriented software systems.

What does SOLID stands for?

The SOLID acronym stands for:

  • S - Single-responsiblity Principle
  • O - Open closed principle
  • L - Liskov Substitution Principle
  • I - Interface Segregation Principle
  • D - Dependency Inversion Principle

This article presents the summary of these 5 principles originally introduced by Robert C. Martin in 2000.

Summary of the SOLID Principles

The SOLID principles include:

  1. Single Responsibility Principle (SRP):

    This principle states that a class, module, or function should have only one reason to change. It should perform a single task. For instance, a class that displays an animal's name should not also handle the display of its sound or feeding habits.

  2. Open-Closed Principle (OCP):

    According to this principle, classes, modules, and functions should be open for extension but closed for modification. This means that you should be able to add new functionality without altering the existing code.

  3. Liskov Substitution Principle (LSP):

    This principle asserts that child classes or subclasses must be interchangeable with their parent classes or superclasses. Essentially, a child class should be able to take the place of its parent class.

  4. Interface Segregation Principle (ISP):

    This principle advises that clients should not be forced to implement interfaces or methods they do not use. It suggests breaking down large interfaces into smaller, more specific ones.

  5. Dependency Inversion Principle (DIP):

    This principle states that high-level modules should not depend on low-level modules. Both should depend on abstractions. Moreover, abstractions should not depend on details; instead, details should depend on abstractions.

These principles can apply to any programming language. Adhering to these principles may result in a larger codebase and can help developers make changes to their code without causing significant issues.

References & Additional Resources

  1. SOLID: The First 5 Principles of Object Oriented Design

  2. SOLID Design Principles in Software Development 

  3. A Solid Guide to SOLID Principles 

GlenH Profile Photo

GlenH - Mar 21, 2024gghayoge at gmail.com

Related Articles

Crafted by GlenH with 🔥 using  React     NextJS,     MDX, Tailwind CSS     & ContentLayer. Hosted on Netlify  

© GlenH.me Contents from 2018 - 2024. Open Source