Walking on water and developing software from a specification are easy if both are frozen.
Edward V Berard

Block Comment

May 25th, 2011 Programming Tags: , ,

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.

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

One Response to “Block Comment”

  • Kevin [ 08Aug11]


    usual_code();
    /* Some description
    * <-- deleting only the slash will still results to a valid comment though
    sometimes_unused();
    sometimes_unused_too();
    /**/
    another_code();

     

Leave a Reply







XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>