OOP vs procedural programming - page 34

 
Andrei:

That's the point - if you isolate everything from everything, it will be many times more difficult to deal with such code, not to mention the impossibility to adequately debug the code when you need to know current values of all necessary variables...

If you write a class, which uses the interface of the trade processor - you should not know current variables inside this interface. Debug the REMOTE part.

If you need to debug the trade processor itself - again, you should debug it, and inside this class you should not know any variables, say, from the input signal generator.

That's the essence of encapsulation - in each place we work only with what we need and don't interfere with other places.

 
Andrei:
It's not about the low level, it's about the logic of what's flowing there and what it's turning into at every possible moment in time, including knowing all the internal variables... Without understanding all this redundant logic, the meaning of using this code for a non-author disappears completely...

Hi...

Do you understand much about how Metatrader works? Do you know any of MT's variables? But that doesn't stop you from using it.

This is what you should do inside your program. There are a number of blocks - they interact using predefined interfaces and do not interfere with each other.

 
George Merts:

If you write a class, which uses the interface of the trade processor - you should not know current variables inside this interface. Debug the REMOTE part.

If you need to debug the trade processor itself - again, you should debug it, and inside this class - you should not know any variables, say, from the input signal generator.

That is the essence of encapsulation - in each particular place we work only with what we need and do not interfere with other places.

If you've ever written a slightly complex computational algorithm, you must have noticed that there are always lots of variables, which need to be processed several times in different places and be able to control their values in different parts of the program at any time... How you can add to this situation encapsulation of all the internal content of the object from the external world is unclear....
 
George Merts:

Hi...

Do you understand much about how Metatrader works? Do you know any of MT's variables? But that doesn't stop you from using it.

You should do so inside your program. There are a number of blocks - they interact using predefined interfaces, and do not interfere with each other.

Be careful, we're not talking about internal MT variables, we're talking about internal object variables that you've isolated, preventing the possibility of reading their values while debugging and writing code...
 
Andrei:
Be careful, we're not talking about internal MT variables, we're talking about internal object variables that you've isolated, preventing the possibility of reading their values while debugging and writing code...

If internal object variables are needed elsewhere, it is no longer internal object variables, you have to think about the logic of building that object (most likely to divide it into smaller objects again). As a last resort, if it's really necessary and there's no other way, a public access Get-method is done in the interface.

 
George Merts:
Andrei is even more clinical than Peter or Sansanych, you are wasting your time
 
Andrei:
If you've ever written a slightly complex computational algorithm, you must have seen that there are always lots of variables, which you need to handle several times in different places and be able to control their values in different parts of the program at any time... How you can add to this situation encapsulation of all the internal content of the object from the external world is unclear....

such a thing shows that it was you who, unfortunately, wrote almost nothing :-(

Such a mess in the system !

 
Ihor Herasko:

If internal object variables are needed elsewhere, they are no longer internal object variables. As a last resort, if it is really needed and there is no other way, a publicly accessible Get-method is done in the interface.

Yes... you can't help but wonder what the heck is in it :) The idea is to have an adequate programming language, to ease debugging and code writing with minimum gestures, and here we have a completely opposite situation...

 
Maxim Kuznetsov:

such a thing shows that it was you who, unfortunately, wrote almost nothing :-(

such a mess in the system !

If only you could be less emotional and reflective and more specific in your discussion, you wouldn't be worth much. :)
 
Andrei:
If you've ever written a slightly complex computational algorithm, you must have noticed that there are always many variables which must be processed several times in different places and you must be able to control their values in different parts of the program at any time... How you can add to this situation encapsulation of all the internal content of an object from the external world is unclear....

Hello.

If one block requires data from another block - an appropriate virtual interface is declared to provide this capability. Here, above, the functionality of the trade processor - is required in different parts of the program, in the generator of inputs, in the controller of trailing and exit, in the controller of stop trades. Each of these program blocks - can refer to the Expert Advisor object, and get trade processor interface. At the same time - no one has direct access to this processor - only through a predefined interface.

It is the same in other places - if some data is required - then this block must provide the appropriate interface.

The point is that any point in the program has access only to the variables it needs, and has no access to any other variables.