Discussing the article: "Design Patterns in software development and MQL5 (part one): Creational Patterns"
I thought the translators made a little mistake in the subsection about abstract factory, but no - the author himself.
Какую проблему проектирования он решает?
So, we can use this template when:
- THERE'S NOTHING
- We need an independent system.
- Need a configured system with one of many product families.
- Need to use a family of related products together as designed and enforce this constraint.
- Need to expose only the interfaces of the provided class, not their implementation.
Examples of using such an Abstract Factory:
In the English source code it is:
What design problem does it solve?
So, we can use this pattern in the case of the following:
- We need an independent system.
- We need a configured system with one of many families of products.
- We need to use a family of related product objects together as per its design and enforce this constraint.
- We need to reveal just interfaces of the provided class, not their implementation.
I'm going to be a little bit more grumpy...
To be precise in terminology, I will look at the English source of the article. So, the author writes "How can we use it in MQL5?" about each template. It should be noted here that MQL5 is an applied specialised language. So what is it? Do we really learn from the material how to use templates in MQL5? No! We see that we just see the implementation of a template in MQL5. Imho, since it is a template, we should first describe it in pseudocode, and only then in MQL5. Ideally, it would be interesting to see practical examples of using design patterns in MQL5. I don't know, maybe I'm getting ahead of myself and the author plans to consider each template in a separate opus. But for now we have what we have....

- www.mql5.com
As someone who knows MQL and also knows and uses OOP at some degrees, but has no idea about design patterns, I have to say I did not understand what you explained.
I did not read it fully, because whats the point of reading paragraph after paragraph if I didn't understand any of them.
The way I'm going to continue learning from this article would be to stick to your code examples only, and try to understand the concept from that.
I wrote this purely to share a feedback.
Thanks again.
void FactoryClient::Switch(AbstractFactory *af) { string sFactory; StringConcatenate(sFactory,sFactory,factory); int iFactory=(int)StringToInteger(sFactory); if(iFactory>0) { Print("Factory client switches the old factory ",factory," to the new one ",af); } else { Print("Factory client accepts the new factory ",af); } Delete(); factory=af; Print("Factory client saved the new factory"); Print("Factory client requests its new factory to create the Product A"); apa=factory.CreateProductA(); Print("Factory client requests its new factory to create the Product B"); apb=factory.CreateProductB(); }
I don't understand this method.
Why can't we compare if these 2 pointers are the same and just use:
if (factory != ap) factory = ap;
Also, the documentation says
int StringConcatenate( string& string_var, // string to form void argument1 // first parameter of any simple type void argument2 // second parameter of any simple type ... // next parameter of any simple type );
and factory is not of a simple type.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Check out the new article: Design Patterns in software development and MQL5 (part one): Creational Patterns.
There are methods that can be used to solve many problems that can be repeated. Once understand how to use these methods it can be very helpful to create your software effectively and apply the concept of DRY ((Do not Repeat Yourself). In this context, the topic of Design Patterns will serve very well because they are patterns that provide solutions to well-described and repeated problems.
Classes of the creational pattern use the inheritance concept to vary the class as an instance, while the object of the creational pattern will give the task of instantiation to another object. When the software focuses more on the object composition than the class inheritance that make creational patterns gain more importance.
We can say that Creational patterns have two recurring themes:
Creational patterns help to apply flexibility in what to create, who, and how it can be created, in addition to when it is created.
They help also abstract the instantiation process because they allow us to create objects without repeating the same implementation and that helps to make our code more flexible and simple.
Author: Mohamed Abdelmaaboud