Art of code comment

  sonic0002        2013-08-19 04:19:40       5,865        0    

Note : This post is just for fun. Please be careful about these tricks.

Code comment is to provide complementary comment to abstract codes. We will introduce two comment styles while we are debugging our codes. we should avoid these styles in production codes.

1. if else style

Only execute eatKfc()

//*                     
eatKfc();
/*/                     
eatMcdonalds();        
//*/

Only execute eatMcdonalds()

/*
eatKfc();
/*/
eatMcdonalds();
//*/

Execute both

//*
eatKfc();
//*/
eatMcdonalds();
//*/

2. Block comment

Don't comment

/**/
var foo = function() {
    ...
};
/**/

Block comment 1

/** /
var foo = function() {
    ...
};
/**/

Block comment 2

/**
var foo = function() {
    ...
};
/**/

These are old age comment styles. Now the advanced IDEs support shortcut keys for commenting some codes.

Source : http://segmentfault.com/a/1190000000265197

STYLE  COMMENT 

       

  RELATED


  0 COMMENT


No comment for this article.



  RANDOM FUN

Santa in Beijing after a busy day

It's a sarcastic picture describing how heavy the haze is in Beijing on Christmas day. Every winter people in Beijing will suffer the heavy haze.