I believe that "single source of truth" is a principle that should always be followed. If there's duplicated code where it'd be a bug if they diverge, then you should refactor. It creates a long-distance coupling in your code that may be invisible to future developers until a bug emerges. But with that in mind, I mostly agree with the article: if it's not a violation of "single source of truth", then abstractions are…
Prefer duplication over the wrong abstraction (2016)
191–200 of 375 posts
Re: Prefer duplication over the wrong abstraction (2016)
#192Re: Prefer duplication over the wrong abstraction (2016)
#193The disadvantages of duplication are greatly reduced in the world of AI. From my experience it can easily detect the duplicates and refactor code safely. On the other hand, code without abstractions is easier to read and easier for AI. With AI, we really need to rethink the clean code principles.
Re: Prefer duplication over the wrong abstraction (2016)
#194I believe that "single source of truth" is a principle that should always be followed. If there's duplicated code where it'd be a bug if they diverge, then you should refactor. It creates a long-distance coupling in your code that may be invisible to future developers until a bug emerges. But with that in mind, I mostly agree with the article: if it's not a violation of "single source of truth", then abstractions are…
With LLMs the cost of duplication is much lower and LLMs
… sometimes duplicate things unnecessarily.
Re: Prefer duplication over the wrong abstraction (2016)
#195I believe that "single source of truth" is a principle that should always be followed. If there's duplicated code where it'd be a bug if they diverge, then you should refactor. It creates a long-distance coupling in your code that may be invisible to future developers until a bug emerges. But with that in mind, I mostly agree with the article: if it's not a violation of "single source of truth", then abstractions are…
Of course, in theory this is true. In practice people tend to avoid ANY duplication no matter what. Especially junior developers, as if duplication would be the root of all evil.
And instead it gets replaced with the actual root of all evil, complexity.
Re: Prefer duplication over the wrong abstraction (2016)
#196With LLMs the cost of duplication is much lower both to write and maintain. So abstractions needs much higher justification.
Re: Prefer duplication over the wrong abstraction (2016)
#197Pro tip - which is the least bad abstraction? Answer: it depends!
Re: Prefer duplication over the wrong abstraction (2016)
#198This is like saying "A slow leak is cheaper than a burst pipe" Yes, okay. But with both you will have a bad time cleaning up. There is a third option: good abstractions. I did see this pattern described in the blog in practice a lot (and fell victim to it myself) and I think that in general this comes down to inexperienced programmers. Object oriented programming makes it worse. Teaching these programmers that they s…
The OP is aware of good abstractions and is describing a procedure for finding them, or for increasing one's chances of finding them.
Re: Prefer duplication over the wrong abstraction (2016)
#199Earlier quoted context omitted.
I get the joke, but in ideal world, in microservices, there is no such thing as code duplication across services. As a maintainer of a service, I should not give a crap about code present in some other service - it's some other team's code, why would I care? I don't have to even know that the other team exists. In big systems, it happens that I can't even feasibly know the existence of all the applications.
You mean you don’t have 300 versions of your badly developed rapidly evolving platform services rotting away underneath the bit you didn’t duplicate?
Being selfish is the core principle of microservice architecture.