First, extract the comment lines using the functions:
public void search(Object a, Object b, boolean flag)
{
commonToThree();
if (flag)
{
affectTwoControllers();
}
else
{
affectsOnlyOne();
}
alsoCommon();
}
flag , :
public void searchWithTrueFlag(Object a, Object b) {
commonToThree();
affectTwoControllers();
alsoCommon();
}
public void searchWithFalseFlag(Object a, Object b) {
commonToThree();
affectsOnlyOne();
alsoCommon();
}