question about Best practice how to code

 

I'm in the middle of bigger project but I'm far from programmer  ...and still learning :)

My question is regarding best practice, how to write the code, I have no problem how to write it to do  what I want it to do, but the question is  what is the best practice

example :

class classContainerTrigger
  {
private:
   ;//                                   ........ P R I V A T E   - F L A G S
   bool              flagDebugLocal;                  //  << permanent debuging features
   bool              flagInitialSetup;                //  << w momencie pierwszego wykonania zmienia sie na false

   string            varClassName;
   datetime          varClassCreatedTime;

   ;// LOG RELATED START  <<<<<
   bool              flagLogAllEventsToFile;             // 
   bool              flagLogAllEventsToFileSecondary;    // 
   string            varLogFileName;
   int               varLogFileCounter;
   ;// LOG RELATED STOP


   int               varArrayIndex;       // 

   void              constructorCommon(void);      //

protected:

public:
   ;//                                   ........ P U B L I C    - V A R I A B L E S
   double            arrayTgSettings[];                  // aktualne ustawienia parametrow
   double            arrayTgDetails[];                   // aktualne wartosci parametrow

   void              classContainerTrigger(int parIndexNo=0);
   void             ~classContainerTrigger(void);

  };

this is just a example, and confusion is regarding arrays.  For variables the best practice is to set them PRIVATE and create SETTERS and GETTERS. Vary tedious but I just doing it, but what about arrays, should they be private to, and I should create all necessary methods regarding those functions  ...is there a article / document where PROS are sharing good practices how to code should look like , habits. I 'd like to my code look good and work well but the think I don't like to comeback to something   in the future because is written not correctly   ... Is  anybody know a good article because if You google it You will find a lot of opinions and I don't know how to filter them :)   ...or maybe the keywords how to look for things like this ??

Regards and thank You

 

You could google for coding guidelines or naming conventions. It's up to you, if it helps to understand your code better then stick with it, personally I prefer the C# style. Flag names start with is/has... like in bool isDone=false

Private/public members: Everything that should not be modified from outside the class should not be made public, so yes, define getters and setters where required.

Array getters: In C# I'd return array content as ReadOnlyCollection (a special interface that will prevent public modifications without creating safety copies). But I think it's not possible here to cast arrays to const, so I would use a getter like GetTgSetting(int at) for individual access and a getter to retrieve a full copy like GetTgSettings(double & settings[])

Reason: