• bloubz@lemmygrad.ml
    link
    fedilink
    arrow-up
    7
    ·
    2 years ago

    Comments should almost always be reserved to “why” and not “what” or “how”. Give extra context that can not be brought in another way. The rest should be clear from the code

    • simple@lemmy.mywire.org
      link
      fedilink
      arrow-up
      7
      ·
      2 years ago

      My “why” comments:

      // This is here because if I remove it, the whole server panics, no idea why. So don't delete it.
      
    • Deebster@lemmyrs.org
      link
      fedilink
      English
      arrow-up
      1
      ·
      2 years ago

      I upvoted this, but actually I hardly ever see this style of commenting. Maybe it’s because I never got very far into corporate coding.

      • Darorad@lemmy.world
        link
        fedilink
        English
        arrow-up
        2
        ·
        2 years ago

        At least in my experience it’s more people just stop leaving comments. Best place I worked had comment review as a part of code review, that was nice

  • JustinFTL@kbin.social
    link
    fedilink
    arrow-up
    6
    ·
    edit-2
    2 years ago

    @odama626 when my brain goes in auto-mode, mine ends up like:

    `// opens dialog window
    openDialogWindow(){

    // set dialog config
    const config = new DialogWindowConfig({…});

    // open window
    dialogWindow.Open(config);
    }`

  • tiny_fingers@programming.dev
    link
    fedilink
    arrow-up
    4
    ·
    2 years ago

    Heheh. Sometimes if it’s getting close to going home time, but I just had an epiphany, I’ll add comments to my code so I can remember my train of thought for the next day. Then I promptly forget to remove the comment after I add the code because I get pulled into some other ‘emergency’.

    • odama626@lemmy.worldOP
      link
      fedilink
      arrow-up
      2
      ·
      2 years ago

      I do this too, will have a list of todos. There is an atlassian vscode extension that lets you create tickets from todos though so that can be pretty helpful

  • dylanTheDeveloper@lemmy.world
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    edit-2
    2 years ago

    I read peoples code submit descriptions and a bunch are extremely detailed, then the ones after from the same user same day are usually “oh this doesn’t work, should work now” or more regularly “iwqrjtqwiuht”