DEV Community

Discussion on: "Do not comment on your code, it should be self-documented". Well... I don't agree.

Collapse
 
po0q profile image
pO0q 🦄 • Edited

You have pretty strong points in your article. I noticed popular programming languages such as PHP are evolving on this point, though. For example, named parameters self-document the code. Union types allow skipping verbose PHPDoc annotations.

IDE can map such features and auto-complete parameters. Probably more efficient than multiple lines of description.

However, nothing is magic, and IT likes catchy slogans and bold statements like "Do not comment your code, it should be self-documentated."

I think it's misleading. The right statement would be "write your comments carefully" or "use comments with caution."

I really appreciate comments that explain the dev's point of view or specific constrainsts that leaded to particular choices. There are always pros and cons, and it's easy to judge someone else's code without the context.