कभी-कभी रणनीति पैटर्न का उपयोग करते समय मुझे लगता है कि कुछ एल्गोरिदम कार्यान्वयन को समान पैरामीटर सूची की आवश्यकता नहीं है।रणनीति पैटर्न में पैरामीटर पैरामीटर
उदाहरण
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
}
}
के लिए वहाँ एक अलग डिजाइन पैटर्न का उपयोग करना चाहिए है?