Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this a good practice? "/*/something/*/something//*/"

/*/ comment here
do some thing.
/*/
do some thing.
//*/

Why people write code like that? Is this a good practice?

like image 656
xeranic Avatar asked Jul 21 '09 03:07

xeranic


2 Answers

It's usually only used when testing something out for the moment. That is, you should never commit code like that to version control, because it can be confusing.

For example, if you are testing two different computation methods, you can use this to switch between them. Personally I have rarely done this, if at all.


For those that don't know, you can toggle between the two code sections by adding one forward slash:

/*/ comment here
do some thing.
/*/
do some thing else.
//*/

//*/ comment here
do some thing.
/*/
do some thing else.
//*/
like image 196
GManNickG Avatar answered Oct 15 '22 17:10

GManNickG


Crappy practice. Dead code has no business hanging around in any production quality code. If there really are situations where the old, dead code would apply, then it should be refactored into something that can be turned on/off using configuration not recompilation.

like image 32
tvanfosson Avatar answered Oct 15 '22 15:10

tvanfosson