Don't use comments. Instead try to name your functions and variables better.
Comments are perfectly fine if they're doing their job correctly. They should focus on why it was done this way rather than what it does.
Bad code and bad comment:
vart=.24;// tax rate
Good code and good comment:
vartaxRate=.24;// tax rate as per the 2018 tax code
The comment expresses that the hardcoded value was set to that, which helps a new developer or future you know why at a glance. They can be more helpful if I actually used functionality as an example rather than variable initialization, but it gets the gist across.
I was reported a wrong result from our accountant. I checked the code: it seems than taxRate has a wrong value, but the comment says it is the tax rate as per the 2018 tax code. I checked on the internet and found that .24 was the tax rate as per the 2017 tax code, the tax rate as per the 2018 tax code is .25. Comment were source of noise.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Comments are perfectly fine if they're doing their job correctly. They should focus on why it was done this way rather than what it does.
Bad code and bad comment:
Good code and good comment:
The comment expresses that the hardcoded value was set to that, which helps a new developer or future you know why at a glance. They can be more helpful if I actually used functionality as an example rather than variable initialization, but it gets the gist across.
I was reported a wrong result from our accountant. I checked the code: it seems than
taxRatehas a wrong value, but the comment says it is thetax rate as per the 2018 tax code. I checked on the internet and found that.24was the tax rate as per the 2017 tax code, the tax rate as per the 2018 tax code is.25. Comment were source of noise.