Kistaro Windrider, Reptillian Situation Assessor (kistaro) wrote,
Kistaro Windrider, Reptillian Situation Assessor

  • Mood:
  • Music:

On Worthless C Comments

So my textbook covers the subject of bad C commenting style. The classic example is
i++; //add 1 to i
but worse can easily be fabricated, like putting the comment in a big flashy box of asterisks. But because of that example, people tend not to really do things like that- especially in code they expect other people to see, right?

I just encountered this litte gem in GnuGo for the TI-89/92+/V200 (was just the TI-89, but I changed that. Yay open source! I also made the cursor work better, implemented handicaps, implemented side selection, improved the endgame code, improved the pass code, fixed a pass-related bug...), in the code global to GnuGo, not the localized code for the calculator:
void genmove(int *i,
             int *j)
/* generate computer move */
   int ti, tj, tval;
   char a;
   int ii, m, n, val;
   int try = 0;   /* number of try */

Let's think about that for a little. Here at the start of this function, there are nine variables being defined. One of them has a name that is a valid English word that represents exactly what the variable means. The other eight are not full words; of them, only two of them are vaguely self-descriptive. So why the fuck does the one that actually adheres to the ideal of self-documenting code get a comment when nothing else does?

*head explodes*

  • Last LJ post

    Hey all, I joined the LJ exodus train before it was cool</hipster>, but with recent developments in LiveJournal server location (…

  • (no subject)

    I want to assemble things that nobody else could ever assemble, and when they are done, I want to have done it in ways that nobody of average skill…

  • Failing, etc.

    That feeling of being 99% sure a social space would have been better for everyone without you in it, but you can't apologize or talk about it or…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded