2 ms·
DRY is about creating a common abstraction for code that is "semantically" equivalent, not "incidentally" equivalent. Even if the code is the same today, is th
by adam_arthur 6y ago
DRY is about creating a common abstraction for code that is "semantically" equivalent, not "incidentally" equivalent.
Even if the code is the same today, is there a case to be made for a new feature that would require them to evolve independently? If so, the "logical" meaning of your function is independent between the two use cases. The code looks the same, incidentally (by accident). Speaking moreso to "domain"/business logic.
And of course, there's the more obvious DRY case of truly context agnostic operations, like math functions, string manipulations etc. Ideally you're using some standard library for these things... agree with the author that it's better to avoid sharing tiny custom libraries if amount of logic is too low to warrant the extra abstraction. The cost of abstraction is not fixed, of course, but dependent on how common and familiar that abstraction is to the broader audience.