Art of code comment

  sonic0002        2013-08-19 04:19:40       5,842        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

Product and the code behind it