Coding in style in 60 seconds - Comments
Welcome to Coding in Style in 60 seconds. This is Dragos and you are watching a series of short videos about how we can improve our code.
This is the fifth episode when we start dealing with comments. The topic is extensive so we’ll spend few videos talking about it.
I bet you heard often something like the following:
“You should document your code.”
“The more comments the better.”
“Every variable, method and class should have a comment.”
Really?!? What if you went to a park and you found signs saying:
“This is a tree”, “That is a river”, “Up is the sky”, “Down is the grass”
Wouldn’t that be useless? Not only useless but pretty stupid? Of course, it would.
Here is the final truth about the comments: They are evil. You should never ever use them. Stay away from them as much as you can!
Except, of course, when you can’t. If you cannot in any way make your code clear without using a comment, then use it as a necessary evil.
So if you think your code needs some comments so a developer, or yourself for that matter, can understand it in 1 year from now, try first to improve the code so it does not need them.
We’ll continue this topic in the next videos.
Thank you for watching. This was the fifth episode of this series. To learn more about how to improve your code or to download for free the Coding in Style book, check our website adelante.ca.