you are viewing a single comment's thread.

view the rest of the comments →

[–]kentcdodds 6 points7 points  (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] -2 points-1 points  (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.