Separating responsibilities
Let’s see what the separation of responsibilities in the code consists of, to make it cleaner, understandable, maintainable, and extensible. This is the first point of the SOLID principles. In the second chapter, this is how we defined the principle of single responsibility: “It means that a class in your code must respond to only one task.”
As a reminder, SOLID is a set of known clean-code rules that, when applied together, will make your code much clearer and more accurate. Rather than trying to follow the five principles described by each of the SOLID caps to the letter, it is more important to have a global idea of all this in mind when you code.
The first step to respect this is, in fact... naming, as we just saw! Indeed, by naming a class properly, clearly, and, above all, precisely, you are already making sure that it doesn’t become a mess where you put a little bit of everything that you can think of. And it is for...