I have a code duplication that I want to avoid but I cannot create a method containing the code because there is a slight difference in a line inside an if. Here's what I mean :
Code 1 :
If case1 ()
{
same code
if()
{
same code
line1
}
Code 2 :
If case2 ()
{
same code
if()
{
same code
line2
}
Both codes are the same except one line (line1 and line2). Since the code is big I want to be be able to copy it inside a function for example. Do you have an idea how to this?
Thanks
You could split your code into multiple methods: