Discussion of article "MQL for "Dummies": How to Design and Construct Object Classes" - page 5

 
joo:

Still, I don't see any advantages of using OOP. ....

So you don't need it for your tasks.
 
DC2008:
So you don't need it for your application.

Or maybe you do, but I don't know about it? :)

Help me figure it out.

 
joo:

... Help me figure this out.

Try rewriting genetic algorithms in oop style. They're just begging to go there.

Besides, you are too lazy to pick up other people's code, but not your own. Start and you will succeed, and at the same time compare the performance of both variants. According to my scrappy statistics, oop slows down the work of programmes.

 
joo:

Still, I don't see any advantages of using OOP. Maybe it prevents me from understanding what kind of beasts such "classes" are.

What you said can be formalised as separate functions. Or not all of them? I'm not being picky, please understand me correctly - I'm trying to understand the principles of OOP.

I would like to see on concrete simple examples the difference in the speed of work of appropriately formatted codes (with and without OOP) and the advantages of OOP in terms of simplicity of project organisation.

It is strange to hear questions about OOP from a developer with your skills ;-). You must be joking. Of course, you can do without OOP and implement everything with functions. But it is simply less convenient from the human point of view - to develop and maintain. OOP does not increase the speed of the program itself.

If we continue the same example with strategy classes, suppose there is a code fragment that should trawl open positions according to their strategies. If we implement it on functions, we will get something like this:

foreach Position in Positions[]
 if StrategyType(Position) == N1 TrailTypeN1(Position);
 else if StrategyType(Position) == N2 TrailTypeN2(Position);
 ...

And if we use OOP:

foreach Position in Positions[]
 Position.Trail;

There are advantages: the record is compact and clear, in case of adding new types of strategies this part of the code will not have to be changed, there is no need to pass (potentially a lot of) parameters or declare instead of them global variables, arrays, which can be inadvertently spoilt from other code sections....

In general, there seem to be a lot of books on this subject. Or is the essence of the question different?

Документация по MQL5: Основы языка / Переменные / Глобальные переменные
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
  • www.mql5.com
Основы языка / Переменные / Глобальные переменные - Документация по MQL5
 
DC2008:

Try rewriting genetic algorithms in the oop style. They are just begging to go there.

After writing the article, the administration suggested/asked me to rewrite it from OOP. I honestly admitted that I don't have a clue. Permission was granted to publish as is.

I'm trying it out. It doesn't work yet. When I redo it, the code with OOP and documentation will be added to the article.

DC2008:

Start and you will succeed, and at the same time compare the performance of both variants. According to my scrappy statistics, oop slows down programs.

Well, you confirm my opinion that code with OOP is less responsive. In my experience of working together with developers who know OOP, the performance decreases quite significantly - up to two times (we compared my code and my partner's code performing the same task).

marketeer:

It is strange to hear questions about OOP from a developer with your skills ;-). You must be joking.

Unfortunately, I'm not joking. Yes, I have grown to the size of a mammoth. Now I'm trying to get rid of atavisms - wool.

marketeer:

Of course, you can do without OOP and implement everything by functions. But it is simply less convenient from the human point of view - to develop and maintain.

Yes, I want "flexibility". That's why I'm interested.

marketeer:

..............

In general, there are a lot of books on this subject. Or is the essence of the question in another way?

Apparently, I do not catch some subtlety. :(

Oh, well. I'll overcome this little wall in my way. :)

 

C'mon...are you kidding?

This isn't a "Dummies" guide for a new programmer trying to learn OOP...it's a bunch of goobleygook. You cut-n-paste some code from an application that is way too obscure to be helpful to a new or beginning programmer.

 
Started researching classes. I came across this article. Yes, yes, I need to insert such a simple interface into my Expert Advisor. I wanted to look at the author's files, but there is nothing there... :-( more precisely in the folder masterwindows-doc.zip, there is an empty help file MasterWindows-Doc.chm Too bad! Maybe everything mentioned in this article is already out of date?
 
Aleksandr Brown:
Started researching classes. I came across this article. Yes, yes, I need to insert such a simple interface into my Expert Advisor. I wanted to look at the author's files, but there is nothing there... :-( more precisely in the folder masterwindows-doc.zip, there is an empty help file MasterWindows-Doc.chm Too bad! Maybe everything mentioned in this article is already out of date?

Checked. The file is fine.

I'll paste it here just in case.

Files:
 
Sergey Pavlov:

Checked. The file's fine.

I'll put it here just in case.

Thank you very much for your consideration. I'll admit, I was a little stupid. I installed a new operating system a couple of days ago, and the security services blocked all downloaded files from the Internet. More precisely, the programmes with the help of which they are opened were launched, but the content of the downloaded file was not displayed. Now everything is set up, and the attached file in the article also opens normally. All very nice and clear, thank you.
 
When trying to compile MasterWindows it complains "'CMasterWindowsEXE::Run' - cannot call protected member function ClassMasterWindows.mqh" on the line "WinEXE.Run()". Can you tell me how to fight it?