A question for OOP experts. - page 42

 
Artyom Trishkin:
Clear classification. If we see that multiple objects have the same properties, it is logical to describe these properties in one parent object.
If a child object overrides a property of a parent object with the same name, this property must be virtual.

What if the object inherits properties and methods from different classes?

If we are dealing with a growing and dynamically rebuilding data structure (Knowledge Base), we need to use "inherited material" of already prepared objects to create new ones. In this case, objects will be synthesized by multiple inheritance, picking up extra inherited material. And therefore, will not function properly. That is, we will come to degenerate objects as soon as multiple inheritance begins. That's the problem...

 
Реter Konow:

What about when an object inherits properties and methods from different classes?

If we are dealing with a growing and dynamically reconstructing data structure (Knowledge Base), we need to use "inherited material" of already prepared objects to create new ones. In this case, objects will be synthesized by multiple inheritance, picking up extra inherited material. And therefore, will not function properly. That is, we will come to degenerate objects as soon as multiple inheritance begins. That's the problem...

In a new object, don't use the properties of "left over" parents. I can see some misunderstanding in you though. Why "give birth" to an object from someone whose properties are not needed?
 
fxsaber:

The relevant toolkit is laid out. No one needs it but the author.

And there is also a need for one. But no one will need it either.

Same situation with KB, articles, etc.


Developers have introduced custom characters, services, ticks, caches, pips,.... I'm surprised they've done that, as it's only a few, if any, who need it.

Let's take the new pips mode of the tester. Who needs it? -No one in fact! It was born as a vision of a significant algorithmic optimization of the tester on the part of its developers. Who understood its usefulness? -Nobody! And so in everything.

Now the Tester is being significantly modified. But these modifications are of no use to anybody. Well, there are geeks who will appreciate it. In its current form, MT5-Tester is cooler than all its competitors. But for some reason they want to make it even cooler. No one is able to assess its current features, not to mention future ones. The developers are several heads above their users. And clearly the motivation for changes in the Tester is not monetisation (it simply cannot be, if no one understands it), but an internal desire to do something unprecedented.

+
 
Artyom Trishkin:
In the new object, don't use properties of "left over" parents. I see some misunderstanding with you though. Why "give birth" to an object from one whose properties are not needed?

Needed, but not completely. The new object uses 3 properties of class A, 5 properties of class B, and 3 methods, of three other classes.

What should it do with the rest of the properties from these classes? How to restrict it from them?

 
Реter Konow:

Needed, but not completely. The new object uses 3 properties of class A, 5 properties of class B, and 3 methods, of three other classes.

What should it do with the rest of the properties from these classes? How to restrict it from them?

Package 3 properties of class A into an object. Inherit from it. Or you can not inherit, and make the object with three properties a property of the required object.
There is a circulatory system - an object with multiple objects. There is a heart object as part of the circulatory system.
For a new object, if a heart is needed in the new object, then inherit from the heart object, not from the circulatory system.
 
Artyom Trishkin:
There is a circulatory system - an object with many objects. There is a heart object as part of the circulatory system.
For a new object, if a heart is needed in the new object, then inherit from the heart object, not the circulatory system.

If a new object needs a heart, it does not need to inherit from a heart. The heart should be made part of the new object, as a member.

Inherit if the new object is an ancestor object. And use inclusion if the new object is WITH the other.

 
Artyom Trishkin:
Pack 3 properties of class A into an object. Inherit from it. Or you can not inherit, but make an object with three properties a property of the required object.

Three properties to combine into an object and make a property of a new object? That's something to think about...

But, inheritance through many long chains generates similar problems at every step. The longer and more diverse the inheritance chains are, the more "mixing" of properties and methods the last generations of objects will get and the harder it will be to derive their individual chain to the base object.

If not inherited - there will be no access to the base object. If inherited, multiple "parentage" of objects prevents traceability of their direct chain to the base object.

It becomes increasingly difficult to isolate their own properties and methods from other classes.

 
Реter Konow:

Three properties to combine into an object and make a property of a new object? That's something to think about...

But, inheritance through many long chains generates similar problems at every step. The longer and more diverse the inheritance chains are, the more "mixing" of properties and methods the last generations of objects will get and the harder it will be to derive their individual chain to the base object.

If not inherited - there will be no access to the base object. If inherited, multiple "parentage" of objects prevents traceability of their direct chain to the base object.

It becomes increasingly difficult to extract their own properties and methods from other classes.

Peter, I highly recommend you

https://en.wikipedia.org/wiki/Code_Complete

Code Complete - Wikipedia
Code Complete - Wikipedia
  • en.wikipedia.org
Code Complete
 
Andrey Barinov:

If the heart is needed in the new object, it is not necessary to inherit from the heart. The heart should be made part of the new object, like a member.

Inherit if the new object IS the ancestor object. And use inclusion if the new object CONTAINS another one.

That's not what I meant. You know what I mean. If you want a modified heart with the properties of the parent.
 
Реter Konow:

Three properties to combine into an object and make a property of a new object? That's something to think about...

But, inheritance through many long chains generates similar problems at every step. The longer and more diverse the inheritance chains are, the more "mixing" of properties and methods the last generations of objects will get and the harder it will be to derive their individual chain to the base object.

If not inherited - there will be no access to the base object. If inherited, multiple "parentage" of objects prevents traceability of their direct chain to the base object.

It becomes increasingly difficult to isolate their own properties and methods from other classes.

Peter. That's why I say no mindless inheritance. A clear division and classification.
Reason: