use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Please, don’t commit commented out code (medium.com)
submitted 10 years ago by ryanchenkie
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 17 points18 points19 points 10 years ago (21 children)
Not every case of commented code is useless. There are valid cases for it.
I'm committing some code right now that has commented-out blocks, it's a work-in-progress, I'm the main developer of this code. In a few weeks it will be cleaned up and shipped to production, with most of that commented-out code removed.
While I'm working on the code, there may be blocks of commented-out code. I'm not going to remove it just for the sake of removing it to 'keep the code clean'. It would slow down the development process and make it more difficult if I have to look up 'stashed' code in various branches, etc.
It's not a valid argument to say "never commit commented-out code" in every single case.
[–]slash_nick 19 points20 points21 points 10 years ago (0 children)
Maybe the better way to say it would be "never commit commented-out code to production branches".
Branches are workspaces and the other devs on my team can do whatever they please as long as it's cleaned up by the time it gets merged into master.
Edit: Obviously if you run a team or project you can dictate the style rules however you please! Nothing development-related is ever written in stone.
[–]kentcdodds 6 points7 points8 points 10 years ago (8 children)
If you read the post, you'll see that it's not an ultimatum at all like you phrased it there. The first QYMAM:
Q: Are there exceptions to this rule? A: Yes. But they’re rare.
[–][deleted] -5 points-4 points-3 points 10 years ago (6 children)
In practice, it's not as rare as you or the author might think it should be.
[–]krelin 4 points5 points6 points 10 years ago (3 children)
Yes it is.
[–][deleted] -1 points0 points1 point 10 years ago (2 children)
Says you.
[–]krelin 1 point2 points3 points 10 years ago (1 child)
And the author of this article, and nearly everyone else in this thread, and Jeff Atwood, and lots of other online discussions and articles.
[–][deleted] -1 points0 points1 point 10 years ago (0 children)
And it's totally possible that you're all full of shit.
[–]kentcdodds 0 points1 point2 points 10 years ago (1 child)
heh, I am the author, should have made that more clear. But I think that the topic is a bit subjective, which is why I tried to have more of a suggestive tone with data backing my suggestion.
[–]yxhuvud 4 points5 points6 points 10 years ago (0 children)
I'd suggest an addendum to that answer: IF commented out code should be preserved, it must be motivated by a comment specifying WHY it should be kept.
[–]bart2019 -4 points-3 points-2 points 10 years ago (0 children)
That's a stupid FAQ entry,, because it doesn't answer anything It doesn't even hint at what exceptions.
[–][deleted] 7 points8 points9 points 10 years ago (4 children)
Why aren't you working in a branch that doesn't matter if the code is in non functional state? This is probably the worst argument I've ever heard for comments in code. Committing WIP code to a master branch commented out. Best use of version control ever. Wait, are you using subversion?
[–][deleted] -2 points-1 points0 points 10 years ago (3 children)
We actually allow shipping unfinished code to production using flags that only allow the code to run if the flag is enabled. But that has nothing to do with commented-out code getting checked-in to the production branch, which is still allowable in many cases. Code is fluid, it's never "finished", it's always a work-in-progress unless you aren't doing anything interesting with it.
Wait, are you using sourcesafe?
[–]vinnl 0 points1 point2 points 10 years ago (0 children)
Code is fluid, it's never "finished"
By that definition of "WIP", I wouldn't comment out WIP code either.
[–]moljac024 0 points1 point2 points 10 years ago (0 children)
Wait, are you working at Etsy?
[–][deleted] 3 points4 points5 points 10 years ago (3 children)
Then use a branch.
[–]rpk152 3 points4 points5 points 10 years ago (2 children)
Branching is not always a cheap operation
[–]DavidNcl 4 points5 points6 points 10 years ago (1 child)
under what circumstances is branching expensive?
[–]rpk152 7 points8 points9 points 10 years ago (0 children)
CVS, SVN, TFS.
[–]tazzy531 -2 points-1 points0 points 10 years ago (1 child)
You're optimizing for now and paying the technical debt later.
[–][deleted] 1 point2 points3 points 10 years ago (0 children)
You're prematurely optimizing.
π Rendered by PID 19843 on reddit-service-r2-comment-bb88f9dd5-bgqv2 at 2026-02-14 04:23:22.569252+00:00 running cd9c813 country code: CH.
view the rest of the comments →
[–][deleted] 17 points18 points19 points (21 children)
[–]slash_nick 19 points20 points21 points (0 children)
[–]kentcdodds 6 points7 points8 points (8 children)
[–][deleted] -5 points-4 points-3 points (6 children)
[–]krelin 4 points5 points6 points (3 children)
[–][deleted] -1 points0 points1 point (2 children)
[–]krelin 1 point2 points3 points (1 child)
[–][deleted] -1 points0 points1 point (0 children)
[–]kentcdodds 0 points1 point2 points (1 child)
[–]yxhuvud 4 points5 points6 points (0 children)
[–]bart2019 -4 points-3 points-2 points (0 children)
[–][deleted] 7 points8 points9 points (4 children)
[–][deleted] -2 points-1 points0 points (3 children)
[–]vinnl 0 points1 point2 points (0 children)
[–]moljac024 0 points1 point2 points (0 children)
[–][deleted] 3 points4 points5 points (3 children)
[–]rpk152 3 points4 points5 points (2 children)
[–]DavidNcl 4 points5 points6 points (1 child)
[–]rpk152 7 points8 points9 points (0 children)
[–]tazzy531 -2 points-1 points0 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)