Member-only story
SOLID Software Design Principles-Write better code(OOP)
SOLID is an acronym for principles in coding to write clean and reusable code. SOLID stands for the following principles:
S-Single Responsibility
O-Open/Closed
L-Liskov Substitution
I-Interface Segregation
D-Dependency Inversion
This article will give you a high-level introduction to each principle as well as tell you why each is important.
Single Responsibility Principle
The Single Responsibility Principle is based on the concept that a class should only have one reason to change. A class should only have one responsibility and you should be able to define what the class does in 1 sentence.
The purpose for this is having a class that only has one purpose allows for easier reusability. If a class is doing several different things, it makes it harder to use that class efficiently. You may extend that class and the child class may not use its functionality which is not proper practice. We will talk about proper inheritance later in this article.