20

👀 guilty. Kinda.

Comments
  • 13
    Codebase at $work be like:

    report.run_every(4.hours) # Run every 6 hours

    No joke.
  • 9
    @Root Today I saw a comment before a C++ constructor:

    // Constructor
  • 8
    @Demolishun Adding //class before each class now xD
  • 3
    That is an overly passive-aggressive stop sign. It has its purpose and the ones indirectly responsible very well know why it is there...

    Useless comments in code on the other hand is mostly caused by compliance theater or gets written by code monkeys.
  • 6
    {// start of block
  • 4
    @dowhile

    {// start block

    //Empty line

    //if

    if (var = true)

    //if var = true, do this

    function(); //call function

    //else do this

    else

    //call other function

    otherFunction();

    //Empty line

    }//end of block
  • 1
    What I did used to do but got some comments on was this with early returns and loop breaks/continue:

    While condition {
    If other_condition {
    Statement;
    Continue;
    } // else

    Statement;
    Statement;
    }
  • 1
    Unless you’re doing something complex or a bit weird IMHO you don’t need to comment HOWEVER a documentation is always needed.
  • 2
    Always was a staunch defender of comments for intent.

    We all know how to read code, it's unambiguous. (May be more or less readable, but if it compiles/runs, it's readable). Don't comment what the code does.

    It's what was your reasoning we can't read. Put it in a comment
  • 1
    @hjk101 If you really feel the need to mention that that indeed is an alternate code path in a comment - then just replace the continue statement by turning the other code path into an actual else branch.
Add Comment