Questions on OOP in MQL5 - page 51

 
Sergey Dzyublik:

1. It turns out that the tree data structure is all from the evil one.
2. Poor C++ where class == private struct, what to do, we should probably give up structures and classes.
3. And that's right: no patterns, no sorting by pointers, no memory savings, especially for large objects...
4. We should not forget to forbid using interfaces and template functions, otherwise you won't understand what object you are working with - what a horror...

1. No, why not? If you're talking about tree (or linked list) nodes changing their state, it's simply a matter of arranging access to that state. In terms ofcode functionality, the user should not have access to a node's state.All iteration across nodes should be done by accessing the tree itself: tree.NextNode(myNode) or tree.Parent(myNode), not myNode.NextNode() or myNode.Parent().

I.e. the state being changed should not be publicly available.

2. Look, I took the Sharpe structure because it is impossible to take a reference/pointer to it. I.e. everything is under control of the compiler. If there is no such control, you have to provide for personal control, for example, through appropriate naming of classes. Let's put it this way:

class MyClass_mut; // mutable

class MyClass_immut; // immutable

3, 4. You're wrong. Everything can be implemented ) You just shouldn't think that all the object's data are necessarily copied through the stack. In general case an object contains an internal pointer to the data. It is like smart pointers. Only in case of changeable objects, this pointer must be even smarter)

 
Aleksey Mavrin:

Dmitry, I assure you, I would be happy to laugh at you too, well I love this business) but in this case you exaggerated, even particularly well smiled.

You're just really confused - a SHOT doesn't equal an OBJECT COPY, I've pointed it out to you.

If it's not clear, let me explain for you by example - you have 1000 bytes of object, you need 200 for snapshot, so why copy 800, especially if you have many millions of saved snapshots.

p/s/ And in general. Don't people realize, that patterns is just an elementary example of solving a elementary TYPICAL problem. And in fact the tasks are not elementary, but more complicated. And to solve real problems the patterns are necessary, but often not in pure book form, but adapted to a particular task, possibly combined with each other, possibly with the addition of some improvisation, expressed sometimes in a simplification, if the task allows, or vice versa "weighting" of the realization.

Again, why do you need encapsulation and interfaces - this probably can not be understood if your IQ is below Wasserman, or if you have not participated in real projects, when different parts of the project are changed by different people simultaneously, and not following basic principles of OOPD involves huge costs on catching bugs. Really, why all this for stamping of Expert Advisors for Market))

You confuse algorithms for solving programming tasks with so-called, and nowadays fashionable, " design patterns" related exclusively to OOP. And you confuse a lot of other things, and read inattentively. A little earlier I wrote - use the structure. But if you've read that post and I haven't written about function of copying of the whole class, you would have got to the point that we are adults and there's no need to do extra work with unnecessary structures when we should do everything maturely - just provide the ability to copy the entire class.

 
Aleksey Mavrin:

...

Again, why do you need encapsulation and interfaces - this is probably impossible to understand if your IQ is below Wasserman's, or if you haven't participated in real projects, when different parts of a project are changed by different people at the same time, and non-compliance with elementary principles of OOPD entails huge costs on catching bugs. Really, why all this for stamping of Expert Advisors for market))

.

Sergey Dzyublik:

...
4. I mustn't forget to prohibit usage of interfaces and template functions, otherwise you won't understand what object you are working with - what a horror...

Sometime, somewhere read what interfaces are and why they are needed.

-

Oh, and this... Are you seriously conflating the ability to save all or some fields of an object with the undo/redo function? Let's talk about Photoshop, you know how it's done.

-

And which one of you is all chocolaty and emailing me?

-

What's your problem, anyway? Have I shaken the foundations of your faith in the Holy Patterns?

 
A self-taught amateur who has never seen anything but mql, teaching men how to write programs, it's funny to come in and read)
 

was going through the bookcase here.

Great find: "Introduction to Artificial Intelligence and Expert Systems with illustrations in BASIC" 1987. One of the chapters "The concept of object-oriented programming".

Believe me - NOTHING has changed...

 
Maxim Kuznetsov:

was going through the bookcase here.

Great find: "Introduction to Artificial Intelligence and Expert Systems with illustrations in BASIC" 1987. One of the chapters "The concept of object-oriented programming".

Believe me - NOTHING has changed...

A lot has changed, there wasn't a church of devotees of Holy Design Patterns back then. And the c++ victims club had not yet formed by that time either.

 
Dmitry Fedoseev:

A lot has changed, there was no church of devotees of Holy Design Patterns back then.

there was no church of saint design worshippers back then. this does not exist even now, you can search the runet, if the number of questions on design patterns in runet is very small, it means that it does not exist as a mass, the "book" questions of students do not count.

they have nothing to read, but it's handy when you want to scale a project, in general, the structure of the program is initially correct

 
Dmitry Fedoseev:

A lot has changed, there was no Church of the Holy Patters of Design.

" Design patterns" is just an agreement to call the same frequently occurring things by the same names. And by the way, the term comes from architecture (where sculptures/bridges/portals/portals are concerned).

Sometimes similar things are solved with similar techniques, not necessarily always... But it's useful to agree on the similarity of things and methods in order to understand each other.

But of course, there are those who say "give a fool a glass phallus and he'll break the thing and cut himself".

 
Igor Makanu:

This does not exist even now, you can search the runet, if the number of questions on patterns in runet is very small, then it does not exist as a mass, the "book" questions of students do not count

There's nothing to read, but it's handy when you want to scale a project.

They do not contain anything. How many patterns have you studied?

 
Dmitry Fedoseev:

Nothing is embedded in them. How many patterns have you studied?

What is meant by "studied"?

if i have read the descriptions on several forums, then i have dozens of them

If applied in MQL, then one - the strategy works, it scales, refactoring is easy - I may throw away all unnecessary things for the tester to make it faster, or go straight to a demo - it's generally convenient and practical