Structural Pattern

1. Adapter(Wrapper)

  1. Convert the interface of a class into another interface clients expect.
  2. 有时候一些工具类被设计为复用, 但是由于接口不匹配的问题不能够复用
  3. Adapter会为Adaptee(adapted class)增加一些没有的没有的功能, 用来与应用程序相适配.

  1. 实现方式:
    1. class composition(更加灵活 <- 多态性)
    2. multi-inheritance
  2. Pluggable adaptors
    1. http://stackoverflow.com/questions/27210898/what-is-pluggable-adapter-design-pattern
    2. http://stackoverflow.com/questions/449424/can-anybody-explain-the-concept-of-pluggable-adapter-to-me-with-good-example

adapter向上展现的接口一致的 adapter向下调用的方式一致(通过函数对象\可调用对象\lambda表达式, 这些可以用括号调用的对象, 统称"函子(factor)")

2. Bridge Pattern (Handle/Body)

  1. Decouple an abstraction from ites implementation so that the two can vary independently
  2. 使用继承会使得类的数量大幅度增长, 而桥接模式可以使类的数量保持的比较少

3. Facade[fə'sɑːd] Pattern

  1. Provide a unified interface to a set of interface in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use
  2. 比如:

对于一个可以编译多种语言的编译器, 其底层的scanner, parser, codeGenerator等如何调用, 被compiler给统一起来,用户要编译源代码时,只要调用compile即可s

4. Composite Pattern

Compose objects into tree structures to represent part-whole hierarchies.

Composite lets clients treat individual objects and compositions of objects uniformly

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fanqiliang630

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值