Deciding when copying a small amount of code is clearer than inventing an abstraction

I have two small functions that share about ten lines of code. I could extract a helper, but their needs are already diverging slightly. Every abstraction I try ends up with extra flags and branching to support both. When is a little duplication clearer than forcing unrelated cases through a shared function? I'm starting to think ‘don't repeat yourself’ is easy to misuse when the underlying behavior isn't actually the same.

  • programming-help
  • copying
  • small
  • amount
81

6 replies · Sort: Best

Best

No conversations include a reply from the original poster.