Sometimes, when you "complete functionality" using copy and paste code, you come to the conclusion that it is crippled and crippled so much that any refactoring attempt will actually take a lot of time, much longer than refactoring at the point where it was obvious.
In my personal experience, my favorite “repetition removal method” was the “Extract Method” Resharper functionality (although this is also available in Visual Studio Visual Studio).
Many times I saw repeating code (some outdated application that I support) not as whole methods, but in pieces within separate methods. This provides an excellent opportunity to turn these pieces into methods.
Monster classes also show that they contain more than one functionality. This, in turn, becomes an opportunity to split each individual functionality into its own (hopefully smaller) class.
I have to repeat that doing all this is not a pleasant experience at all (for me), so I really would rather do it right while it is a small ball of dirt, instead of letting a large ball of dirt and then try to fix it.
source share