I find it almost always better to write dumb code like this until I it does what it needs doing. It's much more straight forward, in a very literal sense, to find suitable abstraction and compression from there. DRY is about knowledge representation, not about repetition or boilerplate. Solving the former first in a good way lays the foundation for solving the latter, which can then be done with more powerful abstraction tools such as macros.
That's when I would feel the dumbest programming - undoing what was supposed to be me being smart.
I think I read somewhere that the worst code comes from the wrong abstractions.
> I think I read somewhere that the worst code comes from the wrong abstractions.
I'd say no, it comes from cut & paste :) seriously
Same! Then I abstract. But others never get past cut & paste.
> DRY is about knowledge representation, not about repetition or boilerplate
err, isn't it exactly about not repeating yourself? I mean, for the ultimate aim of representing the thing better, don't repeat it everywhere, ergo encapsulate?
"Every piece of knowledge must have a single, unambiguous, authoritative representation within a system"
To contrast: Data especially can be very repetitive, say you have a bunch of configurations of somewhat similar things, or you have records that represent purchases at a given time of a thing by someone, they will tend to look very similar, maybe even almost the same
DRY is not about reducing this kind of repetition, because this is just like it should be. Sure, you might want to generate/automate repetitive things or compress them into something more readable and so on, but that's not what DRY is about.
Ultimately it is a form of normalization and decoupling. Ideally you want your code to be in a state so when you change things there is as little coordination required as possible.
Yes!
Every piece of information that is in two or more places is wrong in at least one of them. That's as true of code as it is of data.