OOP vs procedural programming

 
Comments not related to the "EA project" have been moved to this topic.
 

I don't want to create a chorus here, but I wonder if supporters of OOP can submit some code solving a problem, which clearly shows that this solution is more efficient than a solution without OOP?


I am a master of solving problems without OOP and would like to fight with a master of solving problems with OOP.

 
Реter Konow:

I don't want to create a chorus here, but I wonder if supporters of OOP can submit some code solving a problem, which clearly shows that this solution is more efficient than a solution without OOP?

I am a problem solver without OOP and would like to fight a problem solver with OOP.

This is not a platform where you can reproduce the comparison - the program is single-page(single-file). Here you can write as you like and the performance and access to the program will remain almost at the same level. Although it is possible to screw up in any style of writing, procedural or OOP.

 
Vitaly Muzichenko:

This is not a platform where you can reproduce the comparison - the programme is single-page(single-file). Here you can write as you like, and performance and access to the program will remain almost at the same level. Although you can screw up in any programming style - procedural or OOP.

I don't quite understand you. What do you mean by "a one-page program"? You can simply compare two different approaches to solving one task. When comparing, we must estimate each solution by the main criteria: the solution itself, code compactness and code readability.


These are the main criteria in programming.

Стилизатор - Работа с исходным кодом - Разработка программ - Справка по MetaEditor
Стилизатор - Работа с исходным кодом - Разработка программ - Справка по MetaEditor
  • www.metatrader5.com
Данная функция предназначена для оформления исходного кода в соответствии с рекомендуемым стандартом. Это позволяет сделать код более читаемым...
 
Реter Konow:

Writing huge blocks of code taking up hundreds of lines. Almost no comments. No OOP. Code in Russian. Everything works very efficiently. I don't have any troubles with orienting in the program, although there are about 100 files connected to it. Probably because I've got used to it and remembered everything a long time ago. The main thing is to know and understand your program, all the rest is secondary. Imho.

We can argue about the "efficiency" of work.

The same applies to modifiability - if your code will be used on quotes of different accuracy - will it need to be modified, and will it be easy to make them?

The main problem in such projects is just making changes. As practice shows, the larger the blocks, the more likely it is that errors will be introduced during modification. The lack of comments is a disadvantage, not a plus. That is why you have to remember a lot of things.

 
Реter Konow:

I don't want to create a chorus here, but I wonder if supporters of OOP can submit some code solving a problem, which clearly shows that this solution is more efficient than a solution without OOP?

I am a master of solving problems without OOP and would like to fight a master of solving problems with OOP.

I have already presented such code above. There is a fully virtual interface within which the trade history is handled. The same system is used in my work with the current position and in other similar places.

It's because of OOP we have full unity of MT4 and MT5, and in MT5 it works regardless of whether it's hedging or netting.

In addition, exactly due to OOP I have, within one EA I can easily use several TS, different in their magics.

In fact, OOP was invented to simplify the code support. At the same time you have to pay a big cost during writing. If you write code, use it without modifications and then remove it, there is no sense to bother with OOP. OOP gives an advantage exactly when the same code is required in many places and periodically it needs to be modified.

Correspondingly, the scope of OOP application and non-application is determined by the necessity of code maintenance and changes.

 
George Merts:

You could argue about "efficiency".

The same goes for modifiability - if your code is to be used on quotes of different accuracy - will it require changes and will it be easy to make them?

The main problem in such projects is just making changes. As practice shows, the larger the blocks, the more likely it is that errors will be introduced during modification. The lack of comments is a disadvantage, not a plus. That is why you have to remember a lot of things.

Versatility of blocks is another criterion for evaluation. Of course, a block must be usable for a wide range of tasks and easily adaptable to changing conditions. This is exactly what I have. For example, I use the so-called "focus" technology. That is, the values of the main parameters are fixed in global variables all the time, and these variables and put in all the blocks.

 
We need to compare in practice. Otherwise it is a useless discussion.
 
Реter Konow:

Block versatility is another evaluation criterion. Certainly, a block should be usable for a wide range of tasks and easily adaptable to changing conditions. This is exactly what I have. For example, I use the so-called "focus" technology. That is, the values of the main parameters are fixed in global variables all the time, and these variables and put in all the blocks.

I'm afraid global variables are also a disadvantage. There should be as few global variables available in all blocks as possible. Just to ensure that each block receives only the data it needs, and wherever possible - only in constant form, so that there is no way to change something that is not supposed to change.

The only two global variables in my projects are CExpert class object, which functions encapsulate functionality of Init(), OnTick() and other events, and CLogFile object - a log-file, which outputs tracing, because tracing macros must work from any place in the program.

To my mind, relying on the memory is not the best solution, at least, because as Sherlock Holmes said - at some moment the needed knowledge will get buried under the heap of unnecessary rubbish. And the memory can fail too.

 
George Merts:

I'm afraid global variables are also a disadvantage. There should be as few global variables available in all blocks as possible. Just to ensure that each block receives only the data it needs, and wherever possible - only in constant form, so that there is no way to change something that is not supposed to change.

The only two global variables in my projects are the CExpert class object, which functions encapsulate functionality of Init(), OnTick() and other events, and CLogFile object - a log file which outputs tracing, because tracing macros have to work from any place in a program.

To rely on memory is not the best solution, at least because, as Sherlock Holmes said, at some moment the required knowledge will get buried under a heap of unnecessary stuff. And the memory can fail too.

You know, behind all these terms and OOP-code I can't see the task you were solving. What was its essence? Please describe it and I will offer you my solution. Then we may compare them by all the possible criteria.
 
Реter Konow:
It needs to be compared in practice. Otherwise this is a useless discussion.

Why "useless"? Very useful.

But how can we compare "ease of support" in practice?

Let's say, a code written as one huge block and a code split into functional parts - introduction of changes in both cases is absolutely the same. The only difference is that in the first case one should remember all the links which will be affected by modification and take them into account. In the second case, since the unit only has access to the links it needs to work - the modification will affect all available links. You don't need to remember anything - consistently adjust everything that is available to the block you want to modify.

That's how to evaluate the difference here ? The amount of work is exactly the same !

Reason: