Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Design patterns 网桥模式和提供者模式相同吗?_Design Patterns - Fatal编程技术网

Design patterns 网桥模式和提供者模式相同吗?

Design patterns 网桥模式和提供者模式相同吗?,design-patterns,Design Patterns,网桥模式与提供者模式相同。我没有看到GoF书 < P>中所提供的提供者模式,我会说它们是“非常相似的”,考虑Steven Metsker的设计模式在C.*中:他提供了PG 71上的数据库驱动程序的桥接模式的实现。当我阅读它时,它看起来像桥服装中的提供者模式。 < P>我会说它们是“非常相似的”,考虑Steven Metsker在C语言中的设计模式:他提供了PG 71上的数据库驱动程序的桥接模式的实现。正如我所读到的,它看起来像Bridge衣服中的提供者模式。不熟悉提供者模式。桥接模式的目的是从相

网桥模式与提供者模式相同。我没有看到GoF书

< P>中所提供的提供者模式,我会说它们是“非常相似的”,考虑Steven Metsker的设计模式在C.*中:他提供了PG 71上的数据库驱动程序的桥接模式的实现。当我阅读它时,它看起来像桥服装中的提供者模式。

< P>我会说它们是“非常相似的”,考虑Steven Metsker在C语言中的设计模式:他提供了PG 71上的数据库驱动程序的桥接模式的实现。正如我所读到的,它看起来像Bridge衣服中的提供者模式。

不熟悉提供者模式。桥接模式的目的是从相应的实现中分离抽象。简化的eg代码:

class Abstraction
{
  IBridge _bridge;
  public Abstraction(IBridge implementation) { _bridge=implementation; }
  public DoStuff() { _bridge.DoStuff(); }
}

interface IBridge
{
  void DoStuff();
}

class BridgeA : IBridge
{
  void DoStuff() {...}
}

class BridgeB : IBridge
{
  void DoStuff() {...}
}

不熟悉提供者模式。桥接模式的目的是从相应的实现中分离抽象。简化的eg代码:

class Abstraction
{
  IBridge _bridge;
  public Abstraction(IBridge implementation) { _bridge=implementation; }
  public DoStuff() { _bridge.DoStuff(); }
}

interface IBridge
{
  void DoStuff();
}

class BridgeA : IBridge
{
  void DoStuff() {...}
}

class BridgeB : IBridge
{
  void DoStuff() {...}
}

也许不同之处在于提供者模式可能会封装许多网桥

我也在问自己同样的问题,发现很难看出其中的区别

我认为提供者模式基本上就是策略模式

一个可能有助于澄清我困惑的问题


IE是的,它们在示例中看起来很相似,但用途不同。

可能不同的是,提供者模式可能会封装许多桥

我也在问自己同样的问题,发现很难看出其中的区别

我认为提供者模式基本上就是策略模式

一个可能有助于澄清我困惑的问题

是的,它们的例子看起来很相似,但目的不同