Here is base code from TeamA
public class BaseClass
{
public Method1();
public Method2();
Other methods...
}
public class A : BaseClass
{
public override Method1();
public override Method2();
}
public class B : BaseClass
{
public override Method1();
public override Method2();
}
public class C : BaseClass
{
public override Method1();
public override Method2();
}
TeamB have to custom above code, and the code have to be the followings:
public class BaseClass1 : BaseClass
{
public override Method1();
}
public class A1 : A
//There is a big problem here,
//if A1 inherit A, then cannot get changes from BaseClass1
//if A1 inherit BaseClass1, then cannot get changes from A
//Same issue to class B1, C1, D1...
{
public override Method1();
}
public class B1 : B
{
public override Method1();
}
public class C1 : C
{
public override Method1();
}
All other teams will use code from TeamB only, they can easily do these:
public class BaseClass2 : BaseClass1
{
public override Method1();
}
public class A2 : A1
//Same problem here with TeamB
{
public override Method1();
}
public class B2 : B1
{
public override Method1();
}
public class C2 : C1
{
public override Method1();
}
The problem is very clear: No matter whatever teams except TeamA, once if we need to custom BaseClass, we have to custom all of classes, which is too heavy!
My question is: Is there a method to re-design code structure from TeamA, make code generic, then we don't have to do heavy customizations?
It's not 100% clear from your question, but I'm guessing this is a situation where you have a core product engineering team (TeamA) that produces the platform code, and a consultant or "professional services" team that then takes the product and implements it for a customer. The professional services team would like to be able to modify things, but also be able to take patches or version upgrades from product engineering without having to do code merges. (Otherwise, the simple solution would be to modify in place rather than extending and overriding.)
If that is the situation, the simple solution is for TeamA to provide a pass-through base class for TeamB to use as an extension point.
//This is what TeamA provides in a release
public class BaseClass
{
public Method1();
public Method2();
}
public class CustomBaseClass : BaseCLass
{
//No code. This is just a pass-through class
}
public class A : CustomBaseClass
{
public override Method1();
public override Method2();
}
public class B : CustomBaseClass
{
public override Method1();
public override Method2();
}
public class C : CustomBaseClass
{
public override Method1();
public override Method2();
}
Then when TeamB needs to customize something about the base class, they only need to do it in one place, and nothing else needs to be changed:
//This is how it looks when TeamB is done with it
public class BaseClass
{
public Method1();
public Method2();
}
public class CustomBaseClass : BaseCLass
{
public override Method1(); //customized now, and will affect all existing classes automatically
}
public class A : CustomBaseClass
{
public override Method1();
public override Method2();
}
public class B : CustomBaseClass
{
public override Method1();
public override Method2();
}
public class C : CustomBaseClass
{
public override Method1();
public override Method2();
}
When TeamB needs to take a product release from TeamA, they get to keep CustomBaseClass (there has to be an agreement it is for customizations only) and update everything else. This way the customizations are forward-compatible and no merges are necessary, just a bit of testing.
//This is how it looks when TeamA provides a new release with a new method
public class BaseClass
{
public Method1();
public Method2();
public NewMethod();
}
public class CustomBaseClass : BaseCLass
{
public override Method1(); //customized now, and will affect all existing classes automatically
}
public class A : CustomBaseClass
{
public override Method1();
public override Method2();
}
public class B : CustomBaseClass
{
public override Method1();
public override Method2();
}
public class C : CustomBaseClass
{
public override Method1();
public override Method2();
}
In this example, TeamA changed the base class, and TeamB didn't have to lift a finger to keep their customizations.