我看到这个成语很多代码库我工作中,它基本上是:这是什么模式/成语?有什么好处?
:接口 - >实现
例如 - >抽象定义getter/setter方法类
interface Foo{
void doSomethingA();
void doSomethingB();
}
abstract class AbstractFoo implements Foo{
protected int x;
protected String y;
int getX(){ return x;}
void setX(int x){ this.x = x;}
String getY(){ return y;}
void setY(String y){ this.y = y;}
}
//One or more concrete classes extending AbstractFoo
是否有这个名称?我能看到的唯一好处是扩展AbstractFoo的类不需要重新实现它们的getter和setter。
也许'Foo'的继承和抽象? – sll 2012-02-24 19:45:53