I am working on an application, where we are reusing components from the base application via inheritance. We expose our application to our child application and the child application may extend our components and modify the behavior of those components. But the trouble is the base application. It changes frequently and can modify a lot of things which troubles our application because of inheritance, but we need to make sure those changes do not affect our child's application. Simply, we don't want the changes that can break the grandchild component to be propagated from the grandparent component. The parent needs to act in the middle and stabilize the incoming changes from the grandparent component and make sure what was already working for the grandchild works fine. Any ideas/suggestions on how we can achieve this? For e.g.
class BaseApplicationComponentA {
foo() {}
//bar() {}
}
class MyApplicationComponentA extends BaseApplicationComponentA {
foo() {
super.foo();
}
}
class ChildApplicationComponentA extends MyApplicationComponentA {
foo() {
super.foo();
}
bar() {
//error, bar does not exist in MyApplicationComponentA
super.bar()
}
}
BaseApplicationComponentA removes the bar method and ChildApplicationComponentA suddenly stops working. Also if ChildApplicationComponentA directly extends BaseApplicationComponentA, same problem.
CodePudding user response:
Sounds like your classes are too large. I would break them down into services and would use interface(s) as unbreakable contract(s) between devs/teams. And if changes are needed in the specific interface(s) - then devs / teams needs to collaborate and agree on changes.