← 返回刚才阅读的位置

知识卡片

结构图卡 · 1971.o.1.b.1.a.2.c.1.a.1.c.2

防腐层分离门面适配器与翻译器

理解等级:高级

防腐层可由几种职责配合,而不把跨模型语义散落在各处:门面在外部系统模型内简化其复杂接口,不改变其模型;适配器接收本地服务请求,转成外部协议下的等价请求;翻译器负责对象和数据的概念转换,可独立于适配器测试。门面在外部接口本来清晰时可以省略。

下图据原书图14.8和相邻正文自绘,虚线表示外部接口清晰时可省略门面、由适配器直达外部系统;服务、适配器、翻译器与门面的具体类名和实例数量依系统而定。

结构图:

classDiagram
 class 本地领域服务
 class 适配器
 class 概念翻译器
 class 外部门面_可选
 class 外部系统
 本地领域服务 --> 适配器 : 请求
 适配器 --> 概念翻译器 : 转换概念对象
 适配器 --> 外部门面_可选 : 外部调用
 外部门面_可选 --> 外部系统 : 简化访问
 适配器 ..> 外部系统 : 无门面时直达
这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 原书第14章|Anticorruption Layer · 查看原书依据

      One way of organizing the design of the ANTICORRUPTION LAYER is as a combination of FACADES, ADAPTERS (both from Gamma et al. 1995), and translators, along with the communication and transport mechanisms usually needed to talk between systems.

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第109章《Anticorruption Layer》(源文件:_epub-src/0321125215_ch14lev1sec8.html;单元02–03) - 结论依据:原文分别限定门面、适配器和翻译器职责,并说明门面不负责模型转换;同节还说明外部系统接口简单或清晰时可不设门面,适配器可向外部系统或其门面发出等价请求。 - 原始内容:One way of organizing the design of the ANTICORRUPTION LAYER is as a combination of FACADES , ADAPTERS (both from Gamma et al. 1995 ), and translators, along with the communication and transport mechanisms usually needed to talk between systems.