13

Am I the only one who doesn't comment my code?

Comments
  • 8
    I hope so
  • 0
    Unfortunately no.
  • 2
    *readies his code-review paddle*
  • 4
    In 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.
  • 0
    @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
  • 2
    I only really comment if deemed necessary, which should be always but turns out I ignore my own self interest as well
  • 4
    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.
  • 1
    @CrankyOldDev amen! Couldn't agree more.
  • 2
    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.
  • 0
    Wouldn't it be funny if @dfox or @trogus said they don't?
  • 0
    @bittersweet True tbh. Most code is self explanatory imo.
  • 0
    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.
  • 0
    Hi guys if you are looking to get the how to hack Instagram account https://instahacker.xyz from the hack someones Instagram online
  • 0
    Thanks for the post and nice to see this here. https://incrediblyedible.org/kinnse...
Add Comment