考慮以下Java
interface
重載超載對比,再次
public interface Script<T> {
public T execute(Map<String,Object> args);
}
然後我們有一個
public interface SubScript<T> extends Script<T> {
public T execute(String knownTypeArgument, Map<String,Object> args);
}
這裏knownTypeArgument
總是由子execute
方法需要。而在SubScript
界面方法public T execute(Map<String,Object> args);
是不需要的。
我的問題是它的標準/正確的做法是定義一個子接口只需添加一個參數還是兩個?
會導致實現中的代碼錯誤如果SubScript
根本沒有定義,並且knownTypeArgument
通過了Map<String,Object> args
?
PS: 兩個execute(String knownTypeArgument, Map<String,Object> args);
和execute(Map<String,Object> args);
應該成爲完全一樣的目的,它只是在某些情況下execute
將需要更多的信息。
PPS:每個計算器規則 正如我在尋找事實/分,我很想念,而不是討論。
您缺少的點已經在[您的上一個問題的答案]中指出(http://stackoverflow.com/questions/15270889/override-disable-super-interface-method)。 – 2013-03-08 09:31:42