What is the fragile base class problem in java?
All what "Colin Pickard" has said is true , and here I want to add some of the best practices to be more protected when you are writing code that may cause this kind of issues in the Java language and especially if your are creating a framework or a library...
public interface MyBehavior {
void doAction();
static class Implementation implements MyBehavior {
public void doAction() {
//do some stuff
}
}
}
// instead of doing extends To a class that have the doAction method
// we will make a [use a] relationShip between the Example class & the Implementation class
public class Example {
private MyBehavior.Implementation helper = new MyBehavior.Implementation();
public void doAction() {
this.helper.doAction();
}
}