OOP vs procedural programming - page 7

 
Реter Konow:
I see. This is an indisputable argument in favour of OOP. Stupidity of the customer and lack of time to fight it and unwillingness to improve somebody else's algorithm.) Yes, you need OOP in this case. I agree.)
It seems to me that you may do without OOP even in this case
 
Реter Konow:
I see. This is an indisputable argument in favor of OOP. Stupidity of the customer and lack of time to fight it and unwillingness to improve somebody else's algorithm.) Yes, you need OOP in this case. I agree).

Why is it stupid? The normal scientific approach is to have everything at your fingertips to allow you to experiment.

 
Реter Konow:
I see. This is an indisputable argument in favour of OOP. Stupidity of the customer and lack of time to fight it and unwillingness to improve somebody else's algorithm.) Yes, you need OOP in this case. I agree).

Simplify

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
struct str
  {
   int               Tickets;
   string            Symbols;
   int               Types;
   double            Lots;
   double            OpenPrice;
   double            StopLoss;
   double            TakeProfit;
   int               Slippage;
   string            Comments;
   int               Magic;
   datetime          Expiration;
   int               Digitss;
   double            Points;
   double            Profit;
   double            Commission;
   double            Swap;
   double            FullProfit;
  };

str Order[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class COrderMass
  {
protected:
   int               m_slippage;
   string            m_symbol;
   int               m_magic;
public:
   void              SetSymbol(string aSymbol)    {m_symbol   = aSymbol;}
   void              SetSlippage(int aSlippage)   {m_slippage = aSlippage;}
   void              SetMagic(int aMagic)         {m_magic    = aMagic;}

                     COrderMass(void);
                     COrderMass(string aSymbol,int aMagic,int aSlippage);
   void              UpdateOrdersMass();
  };
//+------------------------------------------------------------------+
COrderMass :: COrderMass(string aSymbol,int aMagic,int aSlippage):m_symbol(aSymbol),m_magic(aMagic),m_slippage(aSlippage)
  {

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void COrderMass :: UpdateOrdersMass()
  {
   int z=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         if(OrderMagicNumber()==m_magic || m_magic==-1)
            if(OrderSymbol()==m_symbol || m_symbol=="")
              {
               ArrayResize(Order,z+1,1000);
               Order[z].Tickets       = OrderTicket();
               Order[z].Symbols       = OrderSymbol();
               Order[z].Types         = OrderType();
               Order[z].Lots          = OrderLots();
               Order[z].OpenPrice     = OrderOpenPrice();
               Order[z].StopLoss      = OrderStopLoss();
               Order[z].TakeProfit    = OrderTakeProfit();
               Order[z].Slippage      = m_slippage;
               Order[z].Comments      = OrderComment();
               Order[z].Magic         = OrderMagicNumber();
               Order[z].Expiration    = OrderExpiration();
               Order[z].Digitss       = (int)SymbolInfoInteger(Order[z].Symbols,SYMBOL_DIGITS);
               Order[z].Points        = SymbolInfoDouble(Order[z].Symbols,SYMBOL_POINT);
               Order[z].Profit        = OrderProfit();
               Order[z].Commission    = OrderCommission();
               Order[z].Swap          = OrderSwap();
               Order[z].FullProfit    = Order[z].Profit+Order[z].Commission+Order[z].Swap;
               z++;
              }
  }
//+------------------------------------------------------------------+
 

Gentlemen arguers, let's put it this way, if you don't understand OOP, don't know, let's argue then not procedural programming vs. OOP, but procedural programming with pointers to functions vs. procedural programming without pointers to functions.

 
Vladimir Pastushak:

Simplify


or rather solve it with functions

 

OOP is progress. You just have to accept it and start studying it. It may come in handy.

Классы в C++ — урок 10
Классы в C++ — урок 10
  • votes: 74
  • 2012.09.16
  • code-live.ru
Весь реальный мир состоит из объектов. Города состоят из районов, в каждом районе есть свои названия улиц, на каждой улице находятся жилые дома, которые также состоят из объектов. Практически любой материальный предмет можно представить в виде совокупности объектов, из которых он состоит. Допустим, что нам нужно написать программу для учета...
 
Vladimir Pastushak:

Simplify


It may not be a rational approach to load all open orders with all their parameters into an array.

 
Dmitry Fedoseev:

Why is it stupid? The normal scientific approach is to have everything at your fingertips for the possibility of experimentation.

Stupidity or normal approach is a subjective feeling. To me it is pure stupidity. But perhaps I'm not quite right either. I know that I wouldn't do trailing in this way.
 
Dmitry Fedoseev:

Gentlemen arguers, let's put it this way, if you don't understand OOP, don't know, let's argue then not procedural programming vs. OOP, but procedural programming with pointers to functions vs. procedural programming without pointers to functions.

Let's argue whether structured programming - i.e. division of a program into functions - is necessary
 
Реter Konow:
Stupidity or normalcy is a subjective feeling. To me, it's pure stupidity. But perhaps I'm not quite right either. I know I wouldn't do trailing in this way.

Read this post here and react to ithttps://www.mql5.com/ru/forum/213378/page7#comment_5596988

Reason: