DRY isn't about code duplication - it's about knowledge duplication. Sometimes two pieces of code that 'do' the same thing are actually 'about' different things. For instance (a very simple instance):
This is when coupling goes wrong. It seems like a really stupid example, but when DRY goes wrong it's the same thing, but usually just a few steps removed (classes instead of variables, for instance).
When Sandi Metz talks about the 'wrong' abstraction, she means that it's bad when we couple concepts together in code that are actually independent of each other even though the code 'looks' the same. We couple together pieces of knowledege that are actually independent. My favourite number and the second prime number are the same... but they're really nothing to do with each other. One expresses an eternal fact about three, and the other is much more subject to change...
The final kicker: you won't be able to spot knowledge duplication as easily as you can spot code duplication. It becomes apparent much, much later as you build your program.
To correct the correction ;)
DRY isn't about code duplication - it's about knowledge duplication. Sometimes two pieces of code that 'do' the same thing are actually 'about' different things. For instance (a very simple instance):
!!! LET'S DRY IT !!!
but now I ❤️ four!
oh noes!
This is when coupling goes wrong. It seems like a really stupid example, but when DRY goes wrong it's the same thing, but usually just a few steps removed (classes instead of variables, for instance).
When Sandi Metz talks about the 'wrong' abstraction, she means that it's bad when we couple concepts together in code that are actually independent of each other even though the code 'looks' the same. We couple together pieces of knowledege that are actually independent. My favourite number and the second prime number are the same... but they're really nothing to do with each other. One expresses an eternal fact about three, and the other is much more subject to change...
The final kicker: you won't be able to spot knowledge duplication as easily as you can spot code duplication. It becomes apparent much, much later as you build your program.
Honestly best explanation of DRY gone wrong I've seen.
Yes, exactly. Good insight. It's not really much different from what I was trying to say, although you've beautifully expanded the point!