Re:What most young programmers need to learn
by UrMomReadsHN on Monday January 05, 2015 @11:06AM
(#8839438)
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.
[ Parent
| on HN ]
Re:What most young programmers need to learn
by gknoy on Monday January 05, 2015 @12:49PM
(#8840027)
I 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.
Re:What most young programmers need to learn
by danieltillett on Monday January 05, 2015 @05:02PM
(#8841511)
I 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.
Re:What most young programmers need to learn
by UrMomReadsHN on Monday January 05, 2015 @02:45PM
(#8840677)
Thats 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;
//}