DEV Community

Discussion on: You should write a comment on every line of code

Collapse
 
leob profile image
leob

Completely agree, comments are documentation, and documentation is good - it's as much part of the "product' as your code itself is.

I add comments to functions (or other pieces of code) whenever it is not immediately obvious what that function is doing, why it is there, and what its role "within the whole" is.

Whenever I've sourced solutions from StackOverflow or other places I also often add a URL to the source location as a comment.

Some comments have been hidden by the post's author - find out more