4 ms·
No... you are making your code hard to understand to others by doing that. Thats if you check it in like that. Nothing wrong with leaving it there during develo
by UrMomReadsHN 12y ago
No... you are making your code hard to understand to others by doing that. Thats if you check it in like that. Nothing wrong with leaving it there during development.
- gknoy 12y agoI disagree. If I see 25-40 lines of something that LOOKS like it should be simple, it's tempting to replace it with the four line version. A comment which says, "You might think this would be better as {{4 lines}}, but it is too slow... because this/that/etc" can be VERY helpful, so that one doesn't reproduce the problems (and the time fixing) that caused the initial un-simplification in the first place.
- UrMomReadsHN 12y agoThats totally different than just leaving it there without any context at all. Which is what i was referring to. An actual comment is of course helpful, but when people check in code that has been commented out it usually has no explanation at all. Thats the confusion part. I'm talking stuff like this...(and I believe so was the author)... //int foo = 10; int foo = 20; if (bar) //if (foo > 0) { foo++; } //else //{ //foo--; bar = false; //}
- danieltillett 12y agoI do explain in the comments why the simple function was removed and why the complex version is being used. The biggest problem I have found over time is divergence of the simple version from the complex version. I try and avoid this by updating and testing both versions, but whenever you have code duplication there is a risk that they will diverge.