• ☆ Yσɠƚԋσʂ ☆
    link
    fedilink
    arrow-up
    6
    arrow-down
    1
    ·
    2 months ago

    I find DRY often turns into an antipattern because decoupling is far more important than code reuse in practice. Having a function that supports many different code paths can make it very brittle because any changes to it need to consider all the possible use cases. However, if you have two separate functions that are similar, but can evolve independently then you don’t have that problem. As a rule, it’s better to duplicate code first, and then extract parts that turn out to be general purpose functionality once that’s identified through usage, and to put that code into libraries.