3 ms·
Another alternative to DRY is WET: Write Everything Twice. Only make an abstraction on the third code repetition. I started adopting this a few years ago and i
by fingerlocks 6y ago
Another alternative to DRY is WET: Write Everything Twice. Only make an abstraction on the third code repetition.
I started adopting this a few years ago and it’s surprising how seldom I hit three identical, non-trivial code repeats. Saved a lot of hours over the years not making a seemingly prudent generic layer.
- dsego 6y agoThis is a good rule of thumb to adopt in teams and point out in code reviews.
- tomnipotent 6y agoI've found the whole "once is happenstance, twice is coincidence, thrice is a pattern" bit to be far more useful over time than DRY.
- fermienrico 6y agoNothing is more frustrating than having a colleague who never gets things done and are constantly writing abstractions for days. Like bro, you ain't gonna need this - I know you're flexing your abstract methods but it is fucking useless if it will never have more than one overrides.
- amw-zero 6y agoI don’t understand this argument. It’s trivial to de-duplicate an abstraction by just inlining the code. How is that less efficient than duplicating code? At least in the meantime you get the benefit of shared code changes.