The definition of the “Solid Principles” is a set of
principles and practices that aim to improve and have better practices in the
development and creation of classes and the creating of instance objects of a
class. These practices are not always the same, and depend of the type of
object we want to create, in some cases such practices may vary.
Solid doesn't refer to the conventional meaning of the word,
it is actually a game of letter, which represent some principles know in the
computer science community.
The first principle of the “Solid Principles”, is the SRP principle,
which focuses on the development and verification of classes that must have
certain responsibilities and will make a better understanding on which their responsibilities
are. This principle prevents that any changes made to a certain class may
affect other independent class in a given project.
The next principle of the “Solid Principles” is the OCP
principle, which says that any class and/or function should be available for
other classes to extend, in order to write unnecessary code and duplicated
code. The class must be adaptable for modifications of any circumstance given.
The next principle of the “Solid principles” is the LCP,
this principle establishes that classes must be able to be interchange, where
two classes have a common parent or inheritance, this will permit flexibility
in our projects.
The fourth principle, is the ISP principle, which says that
is better to have a lot of interfaces doing certain processes that to have one interface
doing a lot of tasks.
The last principle is the DIP, which says that a class must
have to use abstraction in order to avoid having dependency between classes,
which makes the relationship between classes much more free and natural.
These principles if applied in a correct manner, will make
classes a lot more efficient and therefore better programming projects.
No hay comentarios:
Publicar un comentario