4 ms·
I think we talk about slightly different abstraction levels. I wasn't thinking of the things a compiler will tend to optimize. It was more the times when I ha
by bborud 6y ago
I think we talk about slightly different abstraction levels.
I wasn't thinking of the things a compiler will tend to optimize. It was more the times when I have tried to do too much with some higher level abstraction and suddenly you find that the abstraction isn't a good fit for everything you need to do inside it and that you may even be writing code that becomes very awkward (hard to understand, "abuses" the abstraction, or just very slow).
These things tend to hit in the "oh shit" phase when you have enthusiastically convinced yourself (and your team members) that this is the way to do it, you have written a lot of code where the abstraction still fits and then you stumble upon the cases where it doesn't fit and things get awkward.
DRY is a good principle, but duplication of code that does nearly the same thing may have significantly lower cognitive overhead, be easier to maintain and easier to evolve in some cases. (The trick is to silence that little OCD voice in your head when you come across those cases).