This is probably not the answer you are looking for, but it is not necessarily duplication. It is sometimes misunderstood that if two different functions look the same, they must be reorganized to remove the duplicate. In my humble opinion, THIS IS WRONG.
This is only duplication if they really are replication and an identical or almost identical concept. For this to be duplication (at least the duplication that needs to be removed), itβs not just that they use the same code, but use the same code for the same reason.
It might just be because of the sample you sent, but it was simple enough. Although the implementation of the two properties was identical, there must be some valid business reason that you have these two properties, otherwise the simplest answer is to remove the second property together. However, if you really have two properties, and they just look the same now, this does not mean that they will not diverge in functionality in the future (and this is normal).
The idea is to minimize the complexity and cost of maintenance. You can only do this if your code makes sense and simulates reality, but not if it introduces false comparisons, combining things that just look similar.
http://mooneyblog.mmdbsolutions.com/index.php/2010/07/30/reusable-code-is-bad/
source share