Programming Patterns – Abstract Factory – script MetaTrader 5

Programming Patterns - Abstract Factory - script for MetaTrader 5
Many architectures start with Factory method, then evolve to AF, Prototype, Builder Builder makes complex objects step-by-step. AF makes families of related products. Builder returns the object after all steps are complete. AF returns its object at once. AF classes are often made with Factory Method/Prototype AF can be used instead of Facade to hide … Read more

Programming patterns – Composite – library MetaTrader 5

Programming patterns - Composite - library for MetaTrader 5
/**************************************************************** Programming patterns: Composite pattern Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. /**/ /****************************************************************/ class Component //abstract (interface)   { public:    virtual void         Operation()=0;    virtual void         Add(Component*)=0;    virtual void         Remove(Component*)=0;    virtual Component*   GetChild(int)=0;                      Component() {}                      Component(string name):mname(name)  {} … Read more

Programming patterns – Facade – library MetaTrader 5

Programming patterns - Facade - library for MetaTrader 5
/**************************************************************** Programming patterns – Facade Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher- level interface that makes the subsystem easier to use. /**/ /****************************************************************/ class SubSystemA {public:void OperationA() {Print(“SubSystem A”);}}; /**/ class SubSystemB {public:void OperationB() {Print(“SubSystem B”);}}; /**/ class SubSystemC {public:void OperationC() {Print(“SubSystem C”);}}; /****************************************************************/ class Facade … Read more

Design patterns – Twin – library MetaTrader 5

Design patterns - Twin - library for MetaTrader 5
/**/ #include <SRCPatterns_Main.mqh> namespace Twin { /************************************************************************************** Design patterns – Twin    Modeling multiple inheritance with the Twin pattern. /************************************************************************************** Structure        +——-+        +——-+        |Parent1|        |Parent1|        +——-+        +——-+        | M1()  |        | M2()  |        +——-+        +——-+           ^                 ^           |                 |      +—-|—————–|—-+      | +——+         +——+ |      | |Child1|  twin   |Child1| |      | +——+ ——> +——+ | … Read more

Design patterns – Abstract Factory – library MetaTrader 5

Design patterns - Abstract Factory - library for MetaTrader 5
//+—————-+—————————————————————————————-+ //|    Abstract    | Provide an interface for creating families of related or dependent objects without     | //|     Factory    | specifying their concrete classes.                                                     | //+—————-+—————————————————————————————-+ //|      When      | 1) a system should be independent of how its products are created, composed, and       | //|                | represented. 2) a system should be configured with one of multiple families of         | //|                | … Read more

Design patterns – Builder – library MetaTrader 5

Design patterns - Builder - library for MetaTrader 5
//———————————————————————————————- //BUILDER – A CREATIONAL PATTERN // | INTENT // |  | for a complex object // |  |  | separate its construction from representation // |  |  | same construction process // |  |  |  | can create different representations // | APPLICABILITY —————————————————————————– // |  | algorithm for creating a complex object should be // |  |  | independent of the parts // |  |  |  | … Read more

Design patterns – Factory Method – library MetaTrader 5

Design patterns - Factory Method - library for MetaTrader 5
//FACTORY METHOD ——————————————————————————- // | GROUP // |  | creational // | INTENT // |  | interface for creating an object // |  |  | defers instantiation to subclasses // |  | subclasses decide which class to instantiate // | BENEFITS // |  | aspects of the code that may vary // |  |  | subclass of object that is instantiated // |  | … Read more

Design patterns – Prototype (creational) – library MetaTrader 5

Design patterns - Prototype (creational) - library for MetaTrader 5
//—prototype——————————————————– //   creational design pattern //   —intent //      create objects by copying a prototype //   —benefits—————————————————— //      class of object that is instantiated may vary //      —refactoring problem //         creating an object by specifying a class explicitly //         —solution //            create objects indirectly //            also abstract factory, factory method //   —applicability ———————————————— //      classes to instantiate are specified at run-time //      no … Read more

All creational design patterns – library MetaTrader 5

All creational design patterns - library for MetaTrader 5
//+——————————————————————+ //|                                             PatternOrganizer.mqh | //|                                    2019-2020, dimitri pecheritsa | //|                                                 792112@gmail.com | //+——————————————————————+ //| 23 design patterns                                               | //+——————————————————————+ //   design patterns: elements of reusable object-oriented software //   gof > erich gamma, richard helm, ralph johnson, john vlissides //   published in 1994 //+——————————————————————+ //| classification                                                   | //+——————————————————————+ //   purpose > creational > 5 //      abstract factory, builder, … Read more