I have an architectural question. I usually create methods that further call the following methods. The result is creating a class getting the finished work of the application. Is there an architectural jamb in it or is it in the order of things?
- oneIt seems to me that the jambs are not here. Otherwise, how are all the methods in one class? Then what kind of OOP can we talk about. - Andrew Paramoshkin
2 answers
Usually, each class is created as independent and complete as possible, which is responsible only for its specific part.
If everything is exactly like this, then everything is beautiful!
For example, there is a class engine, which has its own methods of work and properties. A class machine will use a class engine. The engine class is independent of the car. The car also does not depend on a particular class of engine. At the same time, nothing prevents you from creating your own engine class different from the base one and using it for your vehicle object.
You need to understand what a class is, its very essence .... let's say there is a person, a dog, a doctor and an apple - these are 4 different objects and respectively 4 different classes .. It’s impossible for us to have a Dog class “HumanVrachAbloko” because it is nonsense.
Correspondingly, each class has methods, for example, a person and a dog can run; these are their methods, all objects have properties - for example, all these 4 objects have height, this is their property, each object has its own properties.
Also objects can inherit other objects for example - the doctor is essentially a person too, that is, everything that a person can do and a doctor can do ... that is, a doctor inherits a person’s class, but the opposite is not true .. not everyone can do that the doctor is able - these are basic principles that you need to learn.
It is also unlikely that you can find all the logic in one class, because most likely you created a Dog, a Man, a Doctor - a apple - that can walk and heal and bark.