Not all duplicated code should be removed. This is one of the most important parts of the DRY principle to understand.
This article shares some great examples!
> “Don’t Repeat Yourself” was never about code. It’s about knowledge. It’s about cohesion. If two pieces of code represent the exact same knowledge, they will always change together. Having to change them both is risky: you might forget one of them. On the other hand, if two identical pieces of code represent different knowledge, they will change independently. De-duplicating them introduces risk, because changing the knowledge for one object, might accidentally change it for the other object.
> Looking at the reasons for change, is a very powerful modelling heuristic.
Post #440
2.35K