5 ms·
Sandi Metz said in one of her talks that wrong abstractions are worse than duplication and we just tell new developers about duplication because it's the only t
by ajmurmann 9y ago
Sandi Metz said in one of her talks that wrong abstractions are worse than duplication and we just tell new developers about duplication because it's the only thing they understand. Strongly agreed.
- stcredzero 9y agowrong abstractions are worse than duplication This needs to be given a catchy phrasing and spread all across developer communities! WTD == Worse Than Duplication? WAAW == Wrong Abstractions Are Worse?
- jonahx 9y agoIt's a great principle and I reference it frequently, but as a catchy buzzphrase it has the potential to do as much harm as good: it's easy to abuse as an excuse for copy paste programming. Duplication is still bad, and correct abstractions are still good.
- djur 9y agoSee also "premature optimization is the root of all evil", which I occasionally see stretched to include any kind of thinking about the performance characteristics of your code, even down to basic design decisions like data structures or algorithms.
- grandalf 9y agoGreat point. I've found that most codebases have some abstractions that work very well and others that work less well, and simply having awareness of this can help make the code far more readable. For instance, one might say: "The way x is implemented works, but it's not quite the right abstraction, here's why". That is way more informative than saying it's simply the wrong abstraction or considering it good enough and ignoring its deficiencies.
- gcatlin 9y agoPremature abstraction is the root of all evil.
- kirkules 9y agoPremature abstraction is pure mathematics
- deleted 9y ago[deleted]
- jonahx 9y agoLink: https://www.sandimetz.com/blog/2016/1/20/the-wrong-abstraction https://www.sandimetz.com/blog/2016/1/20/the-wrong-abstracti...
- leakyabs 9y agoI feel this in my soul. I work on a JavaScript project now where sometimes two duplicate pieces of code are “refactored” into one function unnecessarily. Just because there are two similar lines doesn’t mean they need to be their own function/class/whatever, especially when it makes it harder to generalize later when you need similar code that DOESN’T make sense to lump in with that abstraction. I keep having to simplify the code and it’s exhausting.
- gowld 9y agoDRY is not the same as adding layers of abstraction.
- catnaroek 9y agoMost programmers wouldn't know an abstraction if it hit them in the face. In fact, I highly doubt that most existing technology stacks allow you to build any abstractions at all, in the original sense of functionality so self-contained that a user can't distinguish it from a programming language primitive, not just syntactically, but also semantically. In particular: (0) If you need to know or care about its implementation details when you use it, it's not an abstraction. (1) If unrelated ad hoc cases are hardcoded together into a single procedure, it's not an abstraction. (2) If it needs fifteen tunable parameters, some combinations of which don't even make sense, it's not an abstraction. At some point in time, programmers discovered that selection (if, switch, pattern mathcing, whatever) could be replaced with dynamically dispatched first-class procedure calls. Since then, they haven't stopped making their code more “abstract” by making their control flow impossible to follow. Alas, this isn't real abstraction, because it doesn't achieve the intended purpose of reducing the number of things you have to keep in your head simultaneously. So, rather than blaming “wrong abstractions”, I'd blame “not real abstractions”.
- com2kid 9y ago> In fact, I highly doubt that most existing technology stacks allow you to build any abstractions at all, in the original sense of functionality so self-contained that a user can't distinguish it from a programming language primitive Two of the most popular languages out there, C++ and JavaScript, are both great at this. Sometimes, too great.
- catnaroek 9y agoAre you serious? How do I define complex numbers (just to give one example) in JavaScript that actually behave like, you know, complex numbers? Recall that: (0) The usual symbol for complex number addition is +. (1) The operation isn't associated to any individual complex number (i.e., it's not an object method), but is rather an intrinsic part of the algebraic structure of the complex numbers. (2) Complex numbers don't have a physical object identity in memory. C++ fares a little better than JavaScript, but not a lot better.