DRY = Don’t repeat yourself

  • William@lemmy.world
    link
    fedilink
    arrow-up
    14
    arrow-down
    2
    ·
    2 days ago

    First off, I generally don’t worry about DRY until there are 3 instances, not 2. With only 2, it’s really easy to over-generalize or have a bad structure for the abstraction.

    But otherwise, I disagree with the article. If it’s complicated enough to bother abstracting the logic, the worst that can happen in the above situation is that you just duplicate that whole class once you discover that it’s not the same. And if that never happens, you only have 1 copy to maintain.

    The code in the article isn’t complicated enough that I’d bother. It even ends up with about the same number of lines of code, hinting that you probably haven’t simplified things much.

    • esa@discuss.tchncs.de
      link
      fedilink
      arrow-up
      1
      ·
      20 hours ago

      Yeah, I’m reminded of how Germanic languages used to have singular, dual and plural. If we’d still had dual, we’d probably also be talking about not abstracting until we actually have a plural.