What is the SOLID?

Tuncay Türk
4 min readJun 1, 2021

--

Solid principles of Object-Oriented Programming Design

Solid is a mnemonic acronym for five design principles introduced by popular American Software Engineer Robert C. Martin in his paper of Design Principles and Design Patterns in 2000. Following these principles provide us; As the project grows, it provides sustainable, flexible, understandable software.

Note: While these principles can apply to various programming languages such as; Java, C#, Php, etc. I’ll follow the pseudocode method by Java syntax to show principles applying. I believe in the power of visual memory so tried to explain by creating images from draw.io and you can use them anywhere if you want.

Bu postu Türkçe okuyun.

1.Single Responsibility Principle

Let’s look at the picture below and ask some questions, shall we?
Imagine, there is a project and there is someone who takes full responsibility as a Software Developer, Analyst, Designer, and Tester to create this project.
Is the project understandable and sustainable even if the project successful? on the other hand, what will happen if our friend, who has all the responsibilities, gets sick :)

Which team can be more successful?

We should not impose multiple responsibilities on a class and there should be only one reason when we want to change it.

Doing Everything Means Doing Nothing Well

We should apply this principle so that our project is more understandable, easier to manage, quick to solve bugs, and easy to manage and fix affected areas when we make changes.

2.Open-Closed Principle

Let’s think about a friend who works as a software developer in our project, would it be right to ask her/him to become a lawyer, or to expect her/h,m to improve herself and increase her/his professional quality?

Which processing makes more sense?

Entities should be open for extension but closed for modification.

Closed for Modification, Open for Extension

A class or function should preserve existing properties and not allow changes. That is, it should not change its behavior but should be able to acquire new features.

3.Liskov Substitution Principle

We have a structure to produce a car that accelerates using a normal engine. And how can an electric car without an engine made from here accelerate?

Do you show all the characteristics of your parent?

Every subclass or derived class should be substitutable for their base or parent class.

My child should act like me!!

Derived classes must use all the properties of the classes from which they are derived. Otherwise, useless, fake codes will appear.

4.Interface Segregation Principle

Let’s say you want to learn only Java and you have two options. Which is more reasonable to attend only java classes or to attend a package course where all C, Php, and Java lessons are explained?

Why do you have to attend volleyball and basketball lessons when we just want to play football?

Larger interfaces should be split into smaller ones

Take what you need!!

Ensure that implementing classes only need to be concerned about the methods that are of interest to them.

5.Dependency Inversion Principle

Let’s say you have a project and you have a Software developer, a tester, an analyst, and a designer in your project. Is it better to manage a project directly with the owner of the company or is it better to work with a manager who has a command of technical details?

Which organization is better?

High-level modules should not depend upon low-level modules

Many companies bankruptcies because they cannot manage their own growing organization

Dependencies between classes should be as low as possible, especially high-level classes should not depend on lower-level classes.

In this article, I started with the history of SOLID principles and then tried to acquire a clear understanding of the why’s and how’s of each principle by using pictures. SOLID principles are valuable tools in your toolbox, ones you should keep in the back of your mind when designing your next feature or application.
if you catch any wrong information share it with me and improve ourselves together.

--

--