Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
anroven3658yIn my experience, the need for comments is often caused by badly written code. In those cases: Don't try to fix bad code with comments.
-
@anroven I agree with this. Whilst I'll comment any function, even if I feel it's obvious. Sometimes I'll write further comments on a piece of code if it's over engineered
-
I only really comment if deemed necessary, which should be always but turns out I ignore my own self interest as well
-
Grrr... so many things to say!
@oskaryil - no, you're not the only one. You might be the only one who admits to it openly, though! 😉
@anroven - I find this view really, really irritating. As soon as a piece of code takes on *any* complexity, you simply cannot assume the next person to read it will think/interpret things the same way as the code author. In any kind of team context or where the code will need to be maintained by anyone else, comments are utterly essential, and not because it's bad code. Self-commenting code is a myth. -
Comments should clarify, not narrate.
Pointless:
// creating a user
$user = new User();
Now if you are running a complex technical function to transform low level data sets, or call a series of jobs on a message queue, handle replies from some annoying inconsistent API... You should absolutely use comments.
I first ask myself: can I write this code so elegantly that it doesn't need comments? Only if it's impossible because the problem is simply too technical, I'll add concise clarifications. -
Depends on the use case. If it is a hack job scraped together in a few minutes to use once then no. If is something I plan to use again or provide to clients then yes.
By default I only comment important bits for future reference (headers on different sections). I charge a source fee to some clients whom may edit later down the line which covers time for adding comments that are more in-depth than "Chech user Key against Server Key". I keep project notes in case I have to edit the code in the future. -
eddie007-56yHi guys if you are looking to get the how to hack Instagram account https://instahacker.xyz from the hack someones Instagram online
Related Rants
Am I the only one who doesn't comment my code?
undefined
js
programming
comment
commenting
bad practice