The Wrong Abstraction (2016)
I can&#x27;t help but wonder if we&#x27;re sometimes using the wrong words for things. In this discussion we keep talking about &quot;code duplication&quot; and &quot;abstraction&quot; hand-in-hand, but I think they&#x27;re almost orthogonal concepts, at least as I think of them.<p>Seeing the same code almost copy-and-pasted in a few places might call for some code-deduplication. But that&#x27;s not necessarily a new &quot;abstraction&quot; in my eyes. It may be, but it also may not be.<p>I&#x27;m struggling to think of a specific example because I fully intended to go to bed before arriving here... But as a really stupid example, let&#x27;s say you have `val a = x + x + x` and `val b = y + y + y` and `val c = z + z + z` in your code. If you write a new function like `fun addThreeTimes(i) = i + i + i`, I don&#x27;t see that as a new abstraction at all. If, however, you invent multiplication, <i>now</i> you&#x27;re at a new abstraction! `val a = x * 3; val b = y * 3`, etc.<p>&quot;Abstraction&quot; to me is about thinking at a different semantic level, not about avoiding copy and paste.<p>Does this resonate with anyone else? Am I missing the point?