September 28th, 2011
(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: email@example.com
Here are five lines of code I found during a review not too long ago. This code had been tested and was ready for release.
for ( int i=0 ; i < this.MyControl.TabPages.Count ; i++ )
this.MyControl.TabPages.Remove ( this.MyControl.TabPages[i] );
Feel free to stare at this for a while and absorb the quality.
When I was at school I had an excellent teacher who taught me how to bench-check a loop. The basic idea is to write down the loop variables, their starting values, and then you step through the loop on paper and update these variables by hand to check that everything works as you expect, especially the edge cases.