Any code of your own that you haven't looked at for six or more months might as well have been written by someone else.
Eagleson's law

Block Comment

We all know what a block comment is, sometimes we use it to comment a bunch of lines of code. And sometimes we might want those lines of code to be uncommented and commented again. In a traditional way, we need to make two modifications each time, at the beginning and at the end of block comment symbol.

For example:

usual_code();

sometimes_unused();
sometimes_unused_too();

another_code();

If we want to comment some lines:

usual_code();
/*
sometimes_unused();
sometimes_unused_too();
*/
another_code();

We modified two spots. Now, I prefer to do just one modification each “toggle” (comment-uncomment switch), so I use this:

usual_code();
/* Some description
*/
sometimes_unused();
sometimes_unused_too();
/**/
another_code();

To comment them:

usual_code();
/* Some description
     <-- only need to delete this part, one spot
sometimes_unused();
sometimes_unused_too();
/**/
another_code();

More efficient. IMHO.

May 25th, 2011 Programming Tags: , , 1 Comment 393 views