Post

Comments are code

Comments are code

Commenting out code

We had some old functionality - webhook endpoints, that we stopped using. The question came up: should we delete them or just comment out the routes because we may want to use them later?

If you ever need the functionality again, you can always retrieve it from version control. Clean code is better than “maybe we will need this later” code.

Explanatory comments

Comments that explain the code need to be meaningful, necessary, and maintained. Outdated or incorrect comments can be worse than no comments at all. Strive for clarity in the code itself so that comments are a last resort and they only provide context that is not obvious from the code.

Conclusion

Comments are code: leaving unused or outdated code in your project only adds clutter and confusion. Having less code makes your application easier to maintain and understand.

This post is licensed under CC BY-NC 4.0 by the author.