Re:The Wrong Abstraction (2016)
by stormdennis on Sunday July 05, 2020 @01:55PM
(#23740507)
Would the risk forgetting to update the comments not be a reason for creating a wrapper method that handled calls to both and contained the relevant advice?
There's nothing inherently wrong with duplication, except that if you change or fix a bug in one, you need to not forget about the other. Creating a single function solves this... but at the potential cost of creating the wrong abstraction.
When you're at only 1 or 2 extra instances of the code, just maintaining a "pointer" to the other case(s) with a comment serves the same purpose.
(Of course, this requires discipline to always include the comments, and to always follow them when making a change.)