SOLID PRINCIPLES

Omayma Khammassi
2 min readJan 7, 2021

--

This article is a simple way to understand Solid principles if you are a beginner developer.
Here is the link to source code in Github
https://github.com/omayma1/SolidPrinciple

SOLID are five design principles of Object-Oriented-Programs that aim to build applications with:

    clean

readable,

adaptable,

testablity,

and scalable Code.

The intention of these principles is to make software designs more understandable, easier to maintain, and easier to extend.

“Solid code makes solid business for the long term.”

Single Responsibility Principle

Classes should have one and only responsibility. So, it has :

One reason to be changed which can be  modifying its single reponsibiliy,
And We need to read one class to understnad its functionality.

This principle is going to be a vital key for easier changes. And if you break something, you break one thing (or fewer), not an entire system.

Open And Closed Principle

The software should be open for extension but closed for modification. In this principle we can apply an important component of the OOP which is polymorphism:

Extend the parent entity to suit the needs of the child entity while leaving the parent intact.

Liskov Substitution Principle

It’s about any class that must be directly replaceable by any of its subclass without errors.

Interface Segregation Principle

Classes only are able to perform behaviors that are useful to achieve their end functionality. Split interfaces to not forcing classes to handle what they don’t need.

Less code, fewer problems, closer deadlines.

Dependency Inversion Principle

One should depend upon abstraction, not concretion. A high-level class must not depend upon a lower level class. Both must depend on upon abstraction. And an abstraction must not depend on details but the details must depend upon abstraction.

For example an object B cannot inherits directly from an another object A .
Instead ,B inhert from the interface of A ,and object A can be reference type of the interface A.

Conclusion

The SOLID principles are the best solution to produce clean code and make maintenance easier.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Omayma Khammassi
Omayma Khammassi

Written by Omayma Khammassi

Software developer and a lifelong learner.Passionate about Dot.Net application and the Microsoft Azure platforms.

No responses yet

Write a response