DRY = Don’t repeat yourself

  • MajorHavoc@programming.dev
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    6 hours ago

    There are plenty of bad abstractions in the wild and novices applying DRY is a common source of them.

    You’re both saying the same thing though. Novices aggressively apply DRY the moment a second bit of identical code appears, while experienced developers often wait for a third copy and then think about whether DRY fits.

    That said, I think "don’t apply DRY too aggressively is the whole point of this discussion, and the person you’re replying to was kind of needlessly disagreeing.

    • Dark Arc@social.packetloss.gg
      link
      fedilink
      English
      arrow-up
      1
      arrow-down
      1
      ·
      edit-2
      2 hours ago

      You’re both saying the same thing though.

      We’re not quite saying the same thing though because …

      It’s not a 2 vs 3 issue. You can have an infinite number of instances of the same logic and it still not be a case for generalization because it’s not actually general … it’s just an infinitely large program. You can also have two copies of the same code that should be reduced because they are general (e.g. you have the exact same algorithm for generating a UUID copied into two different spots). If you’re thinking about it in terms of quantity you’re already doing it wrong.

      It’s not fixable by “just” copying something.

      Those two points are really important points.

      • MajorHavoc@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        55 minutes ago

        If you’re thinking about it in terms of quantity you’re already doing it wrong.

        You’re ignoring that simple principles make great guidelines for not overthinking things.

        And you’re doing so in the context of an article about the dangers of overthinking things.

        You’ve over thought an article about the dangers of overthinking, while alienating potential collaborators with a condescending tone.

        You’re coming across like one of the rookies who need this warning.

        Consider counting to three, before applying DRY. It works.