DEV Community

Discussion on: Don’t comment your code

Collapse
 
matthewbdaly profile image
Matthew Daly

I would also add that if something can be done either as a comment, such as DocBlocks, or as a native type hint of some kind, it should always be done as the latter, and comments should only be added when they can convey additional information that cannot be conveyed purely by type hints. A type hint will be enforced by the language itself, but a comment is harder to enforce and may get out of sync, and there's little point in using comments to duplicate the type hint.