Understanding the SOLID Principles

Today I will talk about the Edward Guiness’ book section titled “Understanding the SOLID Principles”. First of all Solid is an acronym that stands for five principles of object-oriented programming and design. These principles help to avoid dependencies between the classes.

S-Single Responsibility Principle
O-Open/Closed Principle
L-Liskov Substitution Principle
I- Interface Segregation Principle
D-Dependency Inversion Principle

Talking a bit more of these principles we are going to explain each one:
Single Responsibility Principle: This principle states that one class should only have one responsibility so the changes in that class do not end up affecting unrelated critical features on the system. This happens from a single action to a set of processes. You can take a view that a single responsibility refers to a group of related business processes. The stamina and tolerance determine how far you go

Open/closed Principle: This principle talks about that classes should be open for extension but closed for modification, this means that adding new behavior instead of changing the base of a class you should create new classes that inherit from this class and add the behavior there. This helps to avoid errors in child classes

Liskov Substitution Principle: You can pass a new class to an existing function that has been written to work with the base class, and the function will perform its work just as if you had passed an instance of the base class. This principle intended to keep alive and well the working relationship between classes and functions. You should forbid modification of a behavior through the mechanism of inheritance.

Interface Segregation Principle: This principle tells us to divide and conquer. Instead of writing a big interface, divide the interface members and put them together so the class would not be loaded with responsibilities we won't use.

Dependency Inversion: This principle basically tells us to write code that refers to abstract classes and interfaces instead to actual classes.

Comentarios

Entradas populares de este blog

Hidden Figures

Microservices