我有一个接口I1、一个A1实现的抽象类I1和许多扩展的类C1...。nA1
现在,一个类正在为 的MethodC3实现一种特殊行为,其中每个其他扩展类正在实现一种默认行为。methodAI1A1
public interface I1 {
public void methodA();
}
public abstract class A1 implements I1 {
public void methodA(){
//default behaviour
}
//other methods
}
public class C1 extends A1 {
//do nothing regarding methodA, because the default behaviour is desired
//other methods
}
public class C2 extends A1 {
//do nothing regarding methodA, because the default behaviour is desired
//other methods
}
public class C3 extends A1 {
public void methodA(){
//special behaviour
}
//other methods
}
现在,对我来说,这似乎不是最好的解决方案,因为很难找出它C3是覆盖其父级的某些方法。这有最佳实践吗?
慕虎7371278
相关分类