9
有时,当使用策略模式时,我发现某些算法实现不需要相同的参数列表。策略模式中的变化参数
例如
public interface Strategy{
public void algorithm(int num);
}
public class StrategyImpl1 implements Strategy{
public void algorithm(int num){
//num is needed in this implementation to run algorithm
}
}
public class StrategyImpl2 implements Strategy{
public void algorithm(int num){
//num is not needed in this implementation to run algorithm but because im using same
strategy interface I need to pass in parameter
}
}
有没有我应该使用不同的设计模式?