In my project's core library we have a very big class, which is tending to become a God object. One of the reasons is that, over a period of time, tasks which should have been in different modules have been put into this class. For ex -
class HugeClass{
public void DoModuleXJob(){}
public void DoModuleYJob(){}
}
One of the problems in refactoring and moving the unwanted, module specific behavior out of this class is that it will be a lot of work for Module X and Module Y to change their code. As a work around I was thinking about converting these methods into extension methods and then move them to their concerned modules. For ex -
// in module X
static class HugeClassExtensions{
public static void DoModuleXJob(this HugeClass instance){}
}
// in module Y
static class HugeClassExtensions{
public static void DoModuleYJob(this HugeClass instance){}
}
I found that this does not create any compilation problems, as long as Module Y is not using DoModuleXJob and vice-versa, which I am sure about.
Is this a good solution and are there any better methods in such a case?