Ad
  • Custom User Avatar

    The comments in your solution make me ignore it and move on.

  • Custom User Avatar

    Commenting code which does magic now considered a bad practice? By who?
    If it's math magic, it is still magic.
    Names trick does not help here at all, btw.

  • Custom User Avatar

    Are you trolling? This is a one line function which is 8 characters long. We have no control over the function name/ file name. Explaining the programming language/ framework, or in this example, plain old math, is considered a bad practice.

    You may argue that because 'it is helpful to translate the meaning of some obscure argument or return value into something that’s readable.' Or that 'when [the code] is part of the standard library, or incode that you cannot alter, then a helpful clarifying comment can be useful.'

    But to explain math to a future programmer in the comments would be considered harmful noise. This is because important comments will just be ignored after a while.

    The adage: 'Don’t Use a Comment When You Can Use a Function or a Variable' is applicable here. I convert this block to english like so: 'To sum the row of odd numbers, I cube the row index'. I cannot see any value in adding a comment here.

  • Custom User Avatar

    Yes, indeed. Do not write comments where code is clean.

    But...

    How can clean code in this example explain anything? Why you should believe this code is right?
    Another people said so?

  • Custom User Avatar

    Read clean code. It recommends the exact opposite.

  • Custom User Avatar

    To make people who read you solution to understand it.

    Not a best solution with a good explanation in real world worth much more, than ideal solution
    with no explanation.

    Supporting projects with lack of comments is always a pain. Try it once to feel it.

  • Custom User Avatar
  • Custom User Avatar

    "Best Practices" would be to explain solution in comment.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    For rust, even with all tests passing the test fails with this:

    warning: unnecessary parentheses around assigned value, #[warn(unused_parens)] on by default
      --> src/tests.rs:30:27
       |
    30 |         let dice_amount = (1 + seed % 10);
       |                           ^^^^^^^^^^^^^^^
    

    It looks like a problem with test cases' code.

    Looks like it can be bypassed with:

    #![allow(unused_parens)]