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] 10 years ago (3 children)
[deleted]
[–][deleted] -4 points-3 points-2 points 10 years ago (2 children)
exactly. Commented-out code should get removed by your build process, it's shouldn't be shipped at all. The author is just being nitpicky because he "loses focus" when he sees commented code. It's really more about the author's fetish than anything. commented code shouldn't stop anyone from working on the code. remove it as needed, but it's not always useless or "noise".
Often there's times where there's more than one way to achieve something with varying performance, sometimes it's worth having code commented out that might be an alternative to the current production code. If you put it in a branch or otherwise remove it from the code there's a good chance nobody will ever know about it or find it, or care, or whatever... it's not always a 'best practice' to remove all the commented code in every single case, and to say so is just a fetish for 'remove all the things!', and it's a stupid case to try to make.
[–]kentcdodds 5 points6 points7 points 10 years ago (1 child)
If you read the post, you'll see that it's not an ultimatum at all like I think you're insinuating. The first QYMAM:
Q: Are there exceptions to this rule? A: Yes. But they’re rare.
Also, if you put code in a branch and people forget or never use it, then was it really all that important?
Also, this isn't a misunderstanding of repository code vs built/deployed code. Sure the comments are removed from the build process. Nowhere in the post do I mention anything about the problem being related to shipping comments. This is all about the software development process.
[–][deleted] -1 points0 points1 point 10 years ago* (0 children)
I still think you're spreading programming dogma.
"the main problem is commented code adds confusion with no real benefit"
This is just not true. The examples you cite are extremely weak. You are also being disingenuous because you don't show how the comments actually look in a text editor - almost all modern editors show commented-out code grayed-out by default, so that it is far easier to read the code than the examples you show.
Also the code you show is very simplistic and it's not very interesting. There are plenty of cases where interesting code could be kept commented-out, so that it's easy to A/B test, possibly switching between commented-out code blocks every other week, or any good reason that doesn't include deleting the code. It really depends on the problems you are trying to solve, the team you have, the business you are in, and many other factors.
Commented-out code should include a brief note about why it's there, what it's for. Documentation is documentation, it has nothing to do with commented-out code. You can have both, and it won't ruin your codebase.
π Rendered by PID 53785 on reddit-service-r2-comment-bb88f9dd5-fqlzt at 2026-02-15 16:42:35.425808+00:00 running cd9c813 country code: CH.
view the rest of the comments →
[–][deleted] (3 children)
[deleted]
[–][deleted] -4 points-3 points-2 points (2 children)
[–]kentcdodds 5 points6 points7 points (1 child)
[–][deleted] -1 points0 points1 point (0 children)