• Eager Eagle@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    1 year ago

    The liberty to not name things that are obvious.

    and that’s yet another way to end up with hard to read code.

    Variables hold values that have meaning. Learn how to name things and you’ll write good code.

    edit: someone just wrote an article along these lines. The only thing I’d change is the cause-effect relationship between bad names and bad code. IME bad names lead to bad code, not usually the other way around. The reason is that by starting from good name choices, it’s much easier to have a well structured code. And not rarely, bad names lead to mangled up code that screams for a refactoring.

    • exussum@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      This makes me want to write a function for you to add to numbers where the variables are leftumber and rightnumber, instead of x and y.

      • Turun@feddit.de
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Implementing add (and other math operations) in rust for your types has the type signature self and rhs (right hand side).