Single Responsibility: an object must have only one responsibility.
Open-Close: entities should be open for extension, but closed for modification.
Liskov substitution: client objects that are very specific should be replaced by instances of its subtypes.
Interface segregation: small and specific interfaces are better than a generic interface.
Dependency inversion: do not depend on specific implementations, but abstractions
It is a principle that is focused on better use of object orientation and some techniques such as Dependency Inversion (which also involves dependency injection, so do not get confused). It’s probably one of the most important principles for a well done and well structured code.
It is so important that I’ll not give an example about it here, then it will be in the next post, which I will detail the SOLID.
Don’t Repeat Yourself
It is a principle that is focused on the elimination of duplicates and that repeated logics must be eliminated via abstraction and repeated processes should be eliminated via automation.
Once duplications have directly impact on software maintenance, DRY is a highly recommended principle to always be used.
Example of possible applied DRY: