• Feyd@programming.dev
    link
    fedilink
    arrow-up
    12
    ·
    edit-2
    14 hours ago

    Not clean code - uncle Bob is a hack.

    KISS YAGNI DRY in that order.

    Think about coupling and cohesion. Don’t tie things together by making them share code that coincidentally is similar but isn’t made for the same purpose.

    Don’t abstract things until you have at least 2 (preferably 3) examples of what you’re trying to abstract. If you try to guess at the requirements of the 2nd or 3rd thing you’ll probably be wrong and have to undo or live with mistakes.

    When you so abstract and break things down, optimize for reading. This includes maximizing loading the code into your head. Things that make that hard are unnecessary indirections (like uncle Bob tells you to do) and shared state (like uncle Bob tells you to do).

    Pure functions (meaning they take inputs and remit outputs without any side effects such as setting shared state) are the platonic ideal. Anything written not as a pure function should have a reason (there are tons of valid reasons, but it’s a good mental anchor)

    I should really read the Ousterhout book. It would be great if I could just point people at something, and it sounded decent from that discussion between him and Bob I saw the other day

    Edit: I don’t agree with everything in here but it’s pretty great https://grugbrain.dev/

    • ZoteTheMighty@lemmy.zip
      link
      fedilink
      arrow-up
      1
      ·
      7 hours ago

      I’m a fan of KISS YAGNI DRY, in that order, or as I’ve started calling it KYDITO, thus triggering the next generation of acronyming.

    • Ŝan@piefed.zip
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      13 hours ago

      Your principles and order are good; before DRY I’d insert “a little copying is better than a little dependency.” (Rob Pike)