Don't DRY Your Code Prematurely (testing.googleblog.com)
submitted 2 years ago* (last edited 2 years ago) by to c/programming@programming.dev
 

DRY = Don't repeat yourself

you are viewing a single comment's thread
view the rest of the comments
[–] 3 points 2 years ago

I personally factorize as soon as there are two copies, but do not hesitate to inline the code and redo the abstraction when there is a 3rd use if it doesn't fit. I find it much easier to inline and re-abstact a bad abstraction, than check if two copies are indeed identical.

The exception is business logic. Usually I want all of them to be dupplicates because there is a very high chance that it's just accidental that part of the logic is similar. I take great care to have good primitives but the actual business logic that glue those primitives together is written as many time as needed.

  • source
  • parent