Answer the question
In order to leave comments, you need to log in
Can you explain the principles of OOP?
Principles from the article: https://habrahabr.ru/post/140827/
5. Classes must be open for extension, but closed for modification.
A class is not a variable that was 1 but became 2. How can a class change?
6. Interact only with close friends.
What are close and distant friends, how to distinguish them from each other? There is MVC, which clearly states that the controller interacts with the model (one-way) and the model with the view (also one-way). So here they are all friends already registered)
8. A class (or method) should have only one reason for changing.
Here the question is, as in paragraph 5 above, about the changes, but in the description the phrase:
"The principle indicates that the class (as well as the method) should be allocated only one responsibility" - this is understandable, the class should do only one action, but what does the change have to do with it then?
Answer the question
In order to leave comments, you need to log in
These are principles that concern not so much the process of executing a program as its design . All changes in this case are the process of rewriting the source code by the programmer.
The architecture of the application should be designed in such a way that for some change in its functionality, extensions, etc. it would be enough to change the code only in a narrow circle of places, and to add a new one - without changing anything at all, include new elements. This kind of flexibility, ease of maintenance/testing, readability, is the focus of OOD principles, which have been defined for several decades now.
This is a very broad topic that requires a lot of knowledge and experience in OOP. It is better to start with something simple, and not get into the same MVC without at least a basic understanding of these principles.
How can I immediately build a three-story house with an underground floor and gas heating? I have no construction experience, you won’t learn anything from small houses, and the projects of large houses are incomprehensible to me.
Start with small projects and with experience you will begin to understand the basic principles. There is no other way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question