97
Don't DRY Your Code Prematurely
(testing.googleblog.com)
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
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.