Thursday, September 5, 2013

Pre-Encoder Issues – Refactoring

Some minor refactoring (in this case, a fancy term for renaming) was performed.  When adding the new index member to the RPN item class, I decided that using the term operands for the items that are attached to an item was not appropriate.  Operands really refer to operators.  For arrays, attached items are subscripts, and for functions, are arguments.  And when implemented, for single line statements like IF, these will simply be attached items,  Therefore, the operand term was changed to attached.

Another thing that was bothersome was how the number of variables were named.  When programming in C, one convention was to simply prefix the variable with an 'n' character, for example nitems.  But when converting to camel casing, this becomes nItems and m_nItems for a class member.  This looks kind of ugly (an opinion).  Looking at how Qt does naming for inspiration, the convention itemCount is used.  Therefore, all uses of 'n' were replaced with the Count convention.

In the RPN item class, there were a number of access functions for the number of operands and the operands themselves (now called attached) that were not actually being used anywhere.  So these were removed.  (Lesson: Don't added functions until actually needed.)

Finally, table functions and members related to associated codes used the abbreviations assoc and assoc2 (for the second operand associated codes).  These were changed to associated and secondAssociated to make the code a little more readable.

[commit e161cf87e0]