Understading the SOLID principles

In this blog we will talk about five important principles that allows us to implement a object oriented programming in a better way. By following these five simple rules it is likely that our software does not have a large number of errors or that a new implementation breaks our system.

Single responsibility principle 
It principle talks about that a class should have exactly one responsibility. Other way to understand this is that a single responsibility refers to a group of related business group that we need to break down in its constituent parts so each part  will be designated as a responsibility.


Open/closed principle
This principle respect the fact of each class or function should be open for extension but close for modification. In other word, we should create a new class to add new behavior instead add this new behavior over the base class that we are inherited. 


Liskov substitution principle  
The Liskov substitution principles try to keep working relationship between classes alive and well. However, this principles works similar that the last one (open/closed), both avoid modifying the behavior of the base class, but this principle adds the prohibition to modify the behavior through inheritance mechanisms.

Interface segregation principle
This principle could be the most simple because it avoids writing interfaces that burden classes with responsibilities they do not have. Instead of creating complex and large interfaces, we will create a collection of small and discrete interfaces that do have to do with each other.

Dependency inversion principle 
This last principle has an excellent phrase to apply its rule: Depend upon abstraction, not upon concretations. This means that we should write references to the interface or abstract class instead of a reference to the actual classes. The main purpose is to have minimal dependencies over each class.



Edward Guiness (June 24, 2013). From the book “Ace the Programming Interview: 160 Questions and Answers for Success”, John Wiley & Sons, pp. 121-126.

Comentarios

Entradas más populares de este blog

Software cratfsmanship

Moon Machines: The Navigation Computer

Software Architecture