DEV Community


Discussion on: When Code Duplication is the Right Answer w/ Sandi Metz

bgadrian profile image
Adrian B.G.

I think she is a great developer and right to the point.
I think that all principles (like DRY and SOLID) are guidelines not rules, you choose the best approach for each problem, if there are more pro reasons to break a principle so be it.
I think that those 2-3 LOC from the example are ok to duplicate, then coming down to business rules if you try to put them in methods, the next dev will enlarge those methods with the extra conditions, and complica them.

Another approach will be composition and/or FP, you put the +/- operations in very small reusable functions and combine them for each business rule (in a FP manner).

Forem Open with the Forem app