Dev Den

Share this post

1. Introduction to SOLID Principles

devden.raghavan.studio

1. Introduction to SOLID Principles

Building a strong foundation for your software

Raghavan Lakshmana
Dec 13, 2022
1
Share this post

1. Introduction to SOLID Principles

devden.raghavan.studio

What are SOLID principles?

A set of software design principles that were introduced by Robert C. Martin (also known as "Uncle Bob") in his 2000 paper "Design Principles and Design Patterns". The specific acronym "SOLID" was later coined by Michael” to refer to these principles.

These principles are intended to guide designing object-oriented software in a way that is easy to maintain and extend. The principles are:

  • Single Responsibility Principle A class should have only one responsibility, which the class should entirely encapsulate.

  • Open-Closed Principle A class should be open for extension but closed for modification.

  • Liskov Substitution Principle Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.

  • Interface Segregation Principle A client should not be forced to depend on methods it does not use.

  • Dependency Inversion Principle High-level modules should not depend on low-level modules. Both should depend on abstractions.

Is it still relevant in the world of dynamically typed languages?

Yes, it is still relevant in the world of dynamically typed languages. However, these principles are not specific to statically typed languages like Java and C#. They can be applied to any object-oriented language, statically or dynamically typed. Furthermore, SOLID principles can help developers easily design their code to understand, maintain, and extend.

For example, the single responsibility principle can help developers avoid creating classes or functions with multiple responsibilities, making the code difficult to understand and maintain. In addition, by following the SOLID principles, developers can create more modular and flexible code, making it easier to change without introducing unexpected side effects.

Adoption of SOLID Principle in the Tech Industry

Many well-known companies and organizations have emphasized the importance of SOLID principles and used them to guide their software design decisions. Here are a few examples,

  • Microsoft: Microsoft has adopted the SOLID principles as part of its .NET design guidelines. The company encourages developers to use the SOLID principles to design scalable, maintainable, and testable software. Here is an MSDN article on the dangers of violating SOLID principles in C#.

  • Amazon: Amazon uses the SOLID principles as part of its internal software development process. The company has published several articles and presentations about the SOLID principles and how they can be applied to software design. Here is a collection of resources from AWS for designing software architectures.

Why follow the SOLID principles?

Each developer may have their own opinions on how to design their code. However, the SOLID principles provide a common set of principles based on decades of experience in software development. By following these principles, developers can avoid common pitfalls and create code that is more likely to be maintainable and extensible. These principles are not a set of rules that must be strictly followed. Instead, they are guidelines that can help developers make informed design decisions and create better software. Furthermore, by following these principles, developers can create more modular, flexible, and resilient code to change, which can be particularly important in team environments.

Will it make the code performant?

In terms of performance and code neatness, the SOLID principles do not directly affect these aspects of the code. However, by creating code that is easier to understand, maintain, and extend, a developer may be able to make performance improvements and keep the code neat and organized more easily.

Here are the principles in detail,

Dev Den
2. SOLID - Single Responsibility Principle
This is a continuation of the SOLID series Part 1. The single responsibility principle is a software design principle that states that a class or module should have only one reason to change. Here is an example of code that violates the single responsibility principle…
Read more
a year ago · 1 like · Raghavan Lakshmana
Dev Den
3. SOLID - Open/Closed Principle
This is a continuation of the SOLID series Part 1. Open/Closed Principle The open/closed principle states that software entities (classes, modules, functions, etc.) should be open for extension but closed for modification. This means that you should be able to add new functionality to a software system by adding new code without having to modify existing …
Read more
a year ago · Raghavan Lakshmana
Dev Den
4. SOLID - Liskov Substitution Principle
Objects of a superclass should be able to be replaced with objects of its subclasses without causing any errors in the program. In other words, subclasses should be able to extend superclasses' functionality without changing the superclass's behavior. This principle is named after computer scientist Barbara Liskov, who first formulated it in a 1987 conf…
Read more
a year ago · 1 like · Raghavan Lakshmana
Dev Den
5. SOLID - Interface Segregation
A client should not be forced to depend on interfaces it does not use. In other words, a class should not implement interfaces that contain methods the class does not need. This helps to reduce the complexity of a class and makes it easier to understand and maintain. It also promotes code reuse because classes that implement specific interfaces can be u…
Read more
a year ago · 1 like · Raghavan Lakshmana
Dev Den
6. SOLID - Dependency Inversion Principle
The key is that the higher-level component shouldn't know anything about the lower-level component, and the lower-level component should be easily replaceable. This can be achieved by creating an abstract interface that describes the needed functionality and having the high-level modules depend on that interface. The concrete implementation of that func…
Read more
a year ago · 1 like · Raghavan Lakshmana

Thanks for reading Dev Den! Subscribe for free to receive new posts and support my work.

1
Share this post

1. Introduction to SOLID Principles

devden.raghavan.studio
Share
Next
Comments
Top
New
Community

No posts

Ready for more?

© 2024 Substack Inc
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing