Today's Question:  What does your personal desk look like?        GIVE A SHOUT

Art of code comment

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

Share on Facebook  Share on Twitter  Share on Weibo  Share on Reddit 

  RELATED


  0 COMMENT


No comment for this article.