आज मेरी दुविधा यह समझने की कोशिश से उत्पन्न होती है कि रणनीति और ब्रिज पैटर्न को कैसे कार्यान्वित किया जा सकता है, इस पर ओवरलैपिंग क्यों हो रही है।डिज़ाइन पैटर्न - रणनीति और पुल (डिज़ाइन में ओवरलैप)
यहाँ अब यहाँ ब्रिज पैटर्न (एक अमूर्त से एक क्रियान्वयन सार संक्षेप)
// Shapes object structure will not be concerned how they draw themselves
public abstract class Shape {
protected DrawAPI drawAPI;
protected Shape(DrawAPI drawAPI){
this.drawAPI = drawAPI;
}
// This could also be put in the subcla
public void draw() {
drawAPI.drawCircle(radius,x,y);
}
}
है रणनीति पैटर्न है - एक वर्ग व्यवहार या अपने एल्गोरिथ्म रन टाइम पर बदला जा सकता है। एक कैलकुलेटर अपने परिचालन को एक रणनीति
public class Calculator{
private Strategy strategy;
public Calculator(Strategy strategy){
this.strategy = strategy;
}
public int executeStrategy(int num1, int num2){
return strategy.doOperation(num1, num2);
}
}
इन दोनों पैटर्न में कार्यक्षमता को समाहित करने वाली रणनीति वस्तुओं को छोड़ना शामिल है। ब्रिज पैटर्न (स्ट्रक्चरल) और स्ट्रैटजी पैटर्न (व्यवहार) के बीच स्पष्ट अंतर के साथ कृपया मदद करें। मेरे पास एक और भ्रम है कि वे ज्ञान के विभिन्न छतरी के नीचे हैं।
[रणनीति बनाम ब्रिज पैटर्न] का संभावित डुप्लिकेट (http://stackoverflow.com/questions/5863530/strategy-vs-bridge-patterns) –
http://stackoverflow.com/questions/5863530/strategy-vs -ब्रिज-पैटर्न, http://stackoverflow.com/questions/464524/what-is-the-difference-between-the-bridge-pattern-and-the-strategy-pattern – Andrew
रणनीति व्यवहार पैटर्न है और पुल संरचनात्मक पैटर्न है । Http://stackoverflow.com/questions/464524/what-is-the-difference-between-the-bridge-pattern-and-the-strategy-pattern –