OOP, templates and macros in mql5, subtleties and uses - page 7

 
Ilya Malev:

In my opinion, it's not all that bad. There are not so many basic core interfaces in C#, in my opinion (I'm not a C# expert), that their methods cannot be reduced to one basic superclass and then inherited by whoever needs what

What do you mean by "inherit whoever needs what"? To inherit not the whole class but a part of it? ) I don't know such a function
 
Alexey Navoykov:
What do you mean by "inherit what you need"? Inherit not the whole class but a part of it? ) I'm not familiar with such functionality.

No, I meant define many virtual functions and overload them in inheritors as needed.

 
Ilya Malev:

No, I meant define many virtual functions and overload them in inheritors as needed.

It's total chaos and lack of control. Interfaces define abstract methods that must be implemented, not "by necessity". And with your approach if you forget to overload a method somewhere, the program will compile as if nothing had happened, but instead of the needed method it will be called dummy.
 
Alexey Navoykov:
It's total chaos and uncontrollability. Interfaces define abstract methods that must be implemented, not "by necessity". This ensures implementation of these methods at the object. And with your approach if you forget to overload a method somewhere, the program will compile as if nothing had happened but the program will be called instead of the needed method.

Not a blank, but a "not implemented" exception. In C#, it's all over the place.

 
Alexey Navoykov:
... If you forget to overload a method somewhere, the program will compile as if nothing had happened, but instead of the required method a blank one will be called. That's normal...

That's how it works in MQL, by the way ;(.

 
Ilya Malev:

Not a blank, but a "not implemented" exception. In C# too, it seems to be all over the place.

Not the point, you propose to catch bugs at runtime, while these bugs can (and should) be caught at compile time.
 
Vasiliy Sokolov:

That's how it works in MQL, by the way ;(

You mean their standard library? )
 
Alexey Navoykov:
Not the point, you propose to catch bugs at runtime, while these bugs can (and should) be caught at compile time.

I think it's better than building structures like template <,,,,,,,> for classes. It will break your brain before you finish building such a "class system".

 
Ilya Malev:

I think it's better than building structures like template <,,,,,,,> for classes. It will break your brain before you finish building such a "class system".

I'd rather rack my brains with the compiler, but I'll be sure that my program is guaranteed to work correctly and a working method isn't called.
 
Alexey Navoykov:
I'd rather rack my brains with the compiler, but I'll be sure that my program is guaranteed to work correctly and a working method is called, not something crazy.

If the whole thing has a simple base class, which mostly appears everywhere, and then the dynamic casts go, it might work).

Reason: