One of my colleagues believes any in-code comment is considered code smell. Do you agree? Why and why not?

Answer

Unnecessary comments do indeed clutter things up and could be considered code smell, especially when what's being commented is obvious. Sadly, those who do this commenting were conditioned to by their professors when they went to school. I've noticed more unnecessary commenting coming from those who went through schooling vs. those who are self-taught.

That said, comments are necessary when it's not obvious what the code does. Personally, I also comment when changes are made in the code. For example, I might put in:

// 10/11/2017 JLC - Added to support X feature

Datestamping the comments is immensely helpful because then I know when a certain change happened. Changelogs are fine, as are commit comments, as they are datestamped, but putting the date and by who just above where the change occurred can help jog my memory as to why a change happened. At that point, it's just a matter of going back to email to figure out what was really being asked for. It's happened many times where I'll get asked why a certain behavior is happening, I'll see this, correlate it to an email exchange, then say to the person: "Because you requested it back on XXXX date. Check out our email exchange that day." The issue typically gets dropped after that. :)

Hi, I want to learn Writing an essay i saw that your writing skills is perfect because when my teacher give me an task so hire Essay Writer Service and so costly to me

Reply to this…

(8 answers) Take me to the question