3 ms·
I think it's more likely that your "great programmers" simply understand the difference between the same functionality and accidentally similar functionality. T
by jdmichal 9y ago
I think it's more likely that your "great programmers" simply understand the difference between the same functionality and accidentally similar functionality. The latter is where you have two use cases that are very similar, so you spend all this time deduplicating. Then one of the use cases changes... The correct response would be to duplicate the code again, because the two use cases are no longer similar. In reality, they should have never been combined in the first case. They weren't the same; they were only accidentally similar.
But instead what you usually see is minor tweaks to the common functions. Pass in a flag here, tweak the inputs there, add an if statement over yonder... And before you know it, it's all a terrible tangled mess that is full of branches and technical debt. The two use cases have the same functions, but don't even follow the same branches within the functions.
- dllthomas 9y agoYeah, I've been saying that removing accidental similarity isn't improving code but compressing it. "Huffman coding", if you will...
- jacobush 9y agoThank you for putting that into words, and rather few too. I have only felt that anti-pattern before, not had words for it. Does it have a name? If not, we should give it a name!
- whack 9y agoI believe this pattern is referred to as accidental-duplication. Some existing discussions on this: https://softwareengineering.stackexchange.com/questions/300043/illusory-code-duplication/300090 https://softwareengineering.stackexchange.com/questions/3000... http://www.informit.com/articles/article.aspx?p=1313447 http://www.informit.com/articles/article.aspx?p=1313447