4 ms·
As is typical of this type of blog post, it presents a pat story with without considering the trade-offs. Yes, one reason we create reusable abstractions is bec
by nickm12 6y ago
As is typical of this type of blog post, it presents a pat story with without considering the trade-offs. Yes, one reason we create reusable abstractions is because we don't want to repeat ourselves. But another reason we do it is so we can have a component that we can write tests for. An another reason is so that the calling code is simpler to understand and work with. If you copy-paste code, you will lose these benefits.
My experience is that junior programmers tend to error on the side of writing lots of repetitive, boilerplate code and they would produce better code by being more willing to write reusable abstractions. It's the mid-level programmers that err on the side of creating grandiose frameworks with unnecessary abstractions.
Personally I like DRY, I like WET, I like YAGNI. I see them all as tools in my toolbox as a programmer and I find the art is to know when to use which tool. In practice, my code never has the perfect amount of abstraction vs. repetition vs. generalization but I think I keep them in a manageable range and refactor when things start to feel like they're going off the rails.