MQL5 training - page 19

 
papaklass:
Let me ask you a question. What is the fundamental difference between procedural programming and OOP? A few words, that is, the essence of the difference.

To begin with, even the procedural approach implies structures, because it's hard to do without them. This is at least some sort of data organisation.

OOP allows us to comfortably identify abstract entities and the relationships between them at the design stage. And then you can simply code them, even individually, without being particularly concerned with implementation peculiarities.

And it all looks more logical and readable. And it often works faster. And the main thing is that it is implemented quicker. Despite the fact that we may have more code.

 
papaklass:

I wanted you to express your understanding of the issue, not give me a bookish formulation. No means no. I'll tell you about me.

Well, I didn't "give you a book formulation" :) I didn't formulate anything at all - with an explanation. I just assumed that the question was an exam question, the answer to which you already know thanks to the pill. And so it turned out :) I did not refuse to answer about personal experience.

Sometimes it is enough to "feel" the phenomenon and without asking philosophical questions such as "how can it be" and "what is its deeper meaning", simply understand by example how it works. The reference in the Reference Manual to tetris was enough for me and this example was enough for the very, very beginning:

Depending onwhich class object is created, a virtual function of one or another derived class is called.

void CTetrisField::NewShape()
  {
//--- случайным образом создаём одну из 7 возможных фигур
   int nshape=rand()%7;
   switch(nshape)
     {
      case 0: m_shape=new CTetrisShape1; break;
      case 1: m_shape=new CTetrisShape2; break;
      case 2: m_shape=new CTetrisShape3; break;
      case 3: m_shape=new CTetrisShape4; break;
      case 4: m_shape=new CTetrisShape5; break;
      case 5: m_shape=new CTetrisShape6; break;
      case 6: m_shape=new CTetrisShape7; break;
     }
//--- отрисовываем
   m_shape.Draw();
//---
  }

Intuitive creation of objects whose behavior differs depending on the initial data was enough to see. Next - I requested the entire tetris file from the forum, plus the materials of the Reference, libraries, etc. And then it was off and running. Lots of questions on the forum on the subject.

papaklass:

After reading a bunch of information on the website, I still don't understand what OOP is.

We simply have a cardinally different approach. I haven't particularly wondered "what OOP is" from the scientific point of view. - So as not to lose the essence behind a facade of new and incomprehensible terms.

I bluntly went to study the available examples.

papaklass:

After reading a lot of information on the website I still didn't understand what OOP is.

The MQL5 Reference / Fundamentals / Object-Oriented Programming. Just read the page. Apparently, this was enough for me - without the need to look up other definitions in third-party materials.

 
papaklass:

The answer to my question:

Produre programming focuses on actions (verbs), while object-oriented programming focuseson objects, or entities (nouns). This is the main difference.


In theory and practice it is:

Procedural programming answers the question of what to do (verbs) ,
Object-oriented programming verbs and describes(adjectives) the object(nouns).

That is, OOP is a generalizing superstructure of code into meaningful sentences with many parts of speech.


He who speaks only in verbs is allowed to live in procedures.

Who wants to narrate his code, let him write it with OOP.


PS.

How much we are tired of all these programmer theorists, damn it.

Soon I will mercilessly kill the topic "OOP vs Procedures".
 
sergeev:

PS.

I'm sick and tired of all these programmer theorists, damn it.

Soon I'll be mercilessly killing the subjects "OOP vs Procedures".
Why do you have to "kill" them at once? Most beginners in MQL5 are familiar with "procedural programming". And if they have questions about the need and meaning of OOP - they need to be patiently explained/comprehended. Like a teacher at school - the same thing year after year. Explain patiently, - not tell them to fuck off just because the teacher is tired of repeating this topic.
 
sergeev:

PS.

How much we are fed up with all these programming theorists, damn it.

Soon the themes "OOP vs Procedures" will be mercilessly killed.

"Instead of arranging punctuation at will, write a glossary and there will be no one to "mercilessly kill".

But if you read "practitioners" of OOP - it's like a "caste" of highly thoughtful experts in OOP.

MQL5 is a language for all levels of understanding and capabilities, not only for the castaways - the standard examples of indicators and Expert Advisors prove this.

A programming language is not the goal, but the means. If the PP is sufficient to achieve the goal - let it be so. If it is easier and clearer to someone to use OOP - let it be so. And to achieve the goal - there is no fundamental difference - especially in 90% of low-code microfunctional indicators and Expert Advisors, which are mainly written.

 

papaklass:

When you come across a phrase like this at the beginning of a course, it is immediately clear what the whole book is about. And somehow, everything just falls into place. You understand that attributes are object properties, that implementations and methods are the same thing (functions) and, finally, that classes are made up of objects. Not only do objects have attributes (properties) and methods (functions), but they can also interact with each other. At the same time, they (objects) don't need to know the attributes and methods of other objects. That's how classes are created from these building blocks, which also interact with each other.

You have put everything in such a heap that you can't even make porridge out of it))) It can't be that it's written in a book.
 
abolk:

A programming language is not an end, but a means. If PP is sufficient to achieve the goal, so be it. If OOP is clearer and simpler for someone, so be it.

Wise. Judging by my own experience: single currency indicators are written on PP. And the multi-currency Expert Advisor is written using OOP (because without OOP - in my case it wouldn't have appeared at all).
 

Как уже надоели все эти программистские теоретики, блин. 

Soon the "OOP vs Procedures" threads will be mercilessly killed.

This is because people do not understand the advantages, disadvantages, places and ways of using both. An article with such simple examples: PP will give advantages for this task_1 such and disadvantages such, OOP will give advantages for this task_1 such and disadvantages such; PP will give advantages for this task_2 such and disadvantages such, OOP will give advantages for this task_2 such and disadvantages such... I think it's crucial to pay more attention to comparison of classes and interfaces, if the latter appear in five, as subtleties and differences can be complicated for those who are new to OOP. And all with a bias towards solving simple problems, and this is the difficulty - the explanation and examples need to be as simple and short as possible, but using the principles of PP and OOP.

Then it would be possible to crash a thread by sending it to a place where everything is arranged in shelves with simple examples of application, systematized according to some topics.

Yedelkin:
Wise. Judging by my own experience: One-currency indicators are written on PP. And the multi-currency Expert Advisor is written using OOP (without OOP it would not have appeared at all).
Dear Yedelkin! I can send you the procedurally designed multicurrency kernel if you are interested (it works by open bar). The code was written for 4, but it will go on 5 as well - you can compare the performance of both variants on it.
 
-Alexey-: Dear Yedelkin! I can send you a procedurally designed multicurrency kernel if you are interested (works on open bar). The code is written for 4.
I'm for everyone to live in peace and understanding, if possible. As for my posts, I was just describing my understanding of OOP. It (understanding) may be thrice erroneous - but it is "my" understanding. I don't exclude at all that a part of problems which I was able to solve with the help of OOP, can also be solved within the framework of PP. The wisdom of abolk's statement is precisely that"If PP is enough to achieve the goal - so be it.If it's clearer and simpler for someone to use OOP - so be it". I have added an addition to my post.
 
Yedelkin:
I am in favour of everyone living together as amicably as possible and in mutual understanding. As for my messages, I described my understanding of OOP exclusively. It (understanding) may be three times erroneous - but it is "my" understanding. I don't exclude at all that a part of problems which I was able to solve with the help of OOP, can also be solved within the framework of PP. The wisdom of abolk's statement is precisely that"If PP is enough to achieve the goal - so be it.If it's easier and clearer to someone to use OOP - let it be so".
I agree. And in order to fight in the mood for this or that preference, it is best to organize contests-competitions between forum users. There is such a task ...: which approach will win exactly in terms of performance, memory consumption, code size, portability ...?
Reason: