1 This is just a note explaining the additional coding standards I use in
 
   2 the OS/2 port.  These are in addition to the project standards and are designed
 
   3 to enhance the readability and maintenance of the code.  There are two main
 
   4 standards I employ and few minor ones.  Indentation/columner aligned code
 
   5 and variable naming are the key conventions I use.
 
   7 Indentations allow for a very clean look and feel to the code as well as assisting
 
   8 in debugging.  This is really more a stylistic option that just makes the code
 
   9 look better and easier to read.  Basically I put the data declaration type to the left
 
  10 and the variable in column 37 or 41 (9 or ten 4 space tabs from the left margin).
 
  11 All indentations are multiples of 4. Probably the most important indentation
 
  12 standard I use concerns if/else constructs.
 
  16     if (var == 1)  MyFunc();
 
  23     } else if (eVal == ENUM2) {
 
  28 to be ugly, hard to match openning and closing braces, and a bit of pain for
 
  29 some debuggers.  So I use this instead:
 
  42     else if (eVal == ENUM2)
 
  50 This is infinitely more readable, allows for easy matchup of openning and
 
  51 closing braces and is friendlier to debuggers.
 
  53 Another issue in this category is the function call with large number of parameters.
 
  54 Especially if  some of the parameters are function calls themselves.  I find code
 
  57     MyCall2( param, someotherparam, CallAnotherProc(), CallYetAnotherProc(), param2, param3, Yourproc(), param4);
 
  59 to be ugly and hard on some debuggers and some editors/printers don't like trailing
 
  60 out over 100 columns.  I prefer something like this:
 
  72 Much more readable, and debugger and editor friendly.
 
  74 Like I said above all that is mostly style, but below is something that I find
 
  75 partiuclarly irritating about a lot of code in this and other public projects,
 
  76 the haphazard and lazy use of variable names.  How often have you found yourself
 
  77 deep down in a large function and run across something like xd = p or CallProc(val, val2)
 
  78 and you have no idea what xd or p is or where val or val2 are delcared and you
 
  79 have to go spend time to find them?  Waste of time.  Or something like
 
  80 if (val).  Is val an integer you are testing for nonzero or a pointer for nonNULL?
 
  81 You have to back up somewhere or into a class header to find it in order to know.
 
  82 Coders that use one or two character identifiers in anything other than loop
 
  83 controls are basically just lazy.
 
  85 To alleviate a lot of this poor readability I have instuted the following naming
 
  86 conventions in this port.
 
  88 Class data members are alway preceded with a m_.
 
  90 Datatype prefixes are as follows:
 
  93     l  -- long, size_t (specific 32 bit integer)
 
  94     ll -- longlong (64 bit integer)
 
 101     c  -- char/byte (8 bit)
 
 103     s  -- string class string
 
 105     q  -- smart (counted) pointer
 
 108     v  -- user or library defined datatype (can be a struct, typedef, or even
 
 111 So a class member that is a pointer to something is m_pVar.  A pointer to an
 
 112 unsigned long is a pulVal.  rsVal is a reference to a string.
 
 114 Also I use as many desriptive names as possible.  So an int for a box width is
 
 115 nWidth, not w or x.  An unsigned long for a datalength is ulLength not len or l.
 
 116 A class member that is a pointer to client window is m_pClient or
 
 117 m_pvClient, not just client. A wxBrush is vBrush or a handle to a brush is
 
 118 hBrush as opposed to br or hbr and if they were class members then m_vBrush and
 
 121 Some other things you will not find in this port are things like:
 
 123 Large numbers of nested function calls on one line or if statement.
 
 125 Obtuse nonsense like while (*d++ = *s).  What is that?  Instead you will see
 
 136 I hope you will find wxOS2 extremely easy to read, follow, and debug. Unlike
 
 137 a lot of programmers I find writing code to be every bit as much a work of
 
 138 art as of science.  The neatness and appearance of one's code tells a every
 
 139 bit as much about the person writing it as its functionality and correctness.
 
 142 Struggling OS/2 developer.