domingo, 28 de febrero de 2016

Understanding the SOLID Principles

The article called "Understanding the SOLID Principles" written by Edward Guiness is a brief summary that present us the definition of the "SOLID Principles" which is a set of principles that seeks to implement best practices in the creation of objects and classes in specific cases depending on the situation that is presented in the moment. The SOLID word is an acronym that is used to include the Single Responsability Principle (SRP), Open/Closed Principle (OCP), Liskov Substitution Principle (LCP), Interface Segregation Principle (ISP) and the Dependency Inversion Principle (DIP).

The first principle, the Single Responsibility Principle is a principle that focuses on the creation and verification of classes that should have exactly one responsibility which makes the classes more clean in the sense that the classes have only ONE well defined responsibility to do which is a practice that prevents that the modifications implemented in one class cause problems in other areas that apparently are detached of the principal responsibility of the modified class. 

The second principle, the Open/Closed Principle establishes that a class or function should be open for extension but closed for modification which show us that a class have to be constructed in order to be flexible and adaptable for the conditions that exist in the particular situation and that this class doesn't have to be internally modifiable from outside.

The third principle, the Liskov Substitution Principle on the other hand establishes that two classes can be interchangeable where these two classes have an inheritance link between them which provides a characteristic of flexibility to the function.

The fourth principle, the Interface Segregation Principle establishes that is worse to have an interface that to have to do a lot of tasks that many interfaces that have these tasks spread between them causing that the work accomplished for one specific interface is only the required work and the fifth principle , the DIP, establishes that a class have to use interfaces or abstract classes instead of refer to actual classes making with this that the dependency between the classes is diminished and that the class that implements the interfaces can use another interface in an easy way, which is related with the objective of the LCP in the way that the two promote the adaptability of the classes. 

After reading this five principles I can say that when programming we should be aware of them because they help us have a more structured code, cleaner and therefore more readable. Also with these techniques we learn other things about programming and we can make better programs with better quality.

If you're interested in reading this article, here is the link: Understanding the SOLID Principles.

No hay comentarios:

Publicar un comentario