• @lysdexic
    link
    English
    181 year ago

    Duplicate code can be a code smell, but it’s far better to have the same function definition or code block appear twice in the code than extracting a function that tightly couples two components that should not be coupled at all.

    See Write Everything Twice (WET) principle.

    • @[email protected]
      link
      fedilink
      71 year ago

      Also, some of the deep, highly abstract, functional techniques to reduce duplication are too clever for their own good. Your dev team might worship you as a programming God until someone needs to debug it. Back off on that, even if it means duplicating more code.

    • @[email protected]
      link
      fedilink
      31 year ago

      This. Especially if your team does not follow SOLID principles (as then someone fixes a bug in a base class method that shouldn’t be shared. This fixes an issue in a subclass but introduces one in another. Rinse, repeat.