Difference between Bridge pattern and Adapter pattern

后端 未结 9 1036
清歌不尽
清歌不尽 2020-11-29 19:16

What is the difference between the Bridge and Adapter patterns?

9条回答
  •  隐瞒了意图╮
    2020-11-29 20:01

    Looks like shorter and clear answer to me according to another stackoverflow answer here:

    • Adapter is used when you have an abstract interface, and you want to map that interface to another object which has similar functional role, but a different interface.

    • Bridge is very similar to Adapter, but we call it Bridge when you define both the abstract interface and the underlying implementation. I.e. you're not adapting to some legacy or third-party code, you're the designer of all the code but you need to be able to swap out different implementations.

提交回复
热议问题