知识卡片

结构图卡 · 1971.o.1.c.1.b.3.b.1

路线组合统一多层行程行为

理解等级:高级

原书的货运路线教学例子先把 Route 看成扁平 Leg 串。领域专家指出完整行程有门到门与海运等不同区段,部分区段由不同人员在不同时点规划;门口运输的执行方式也不同。若逐层增加专有类型,遍历与生成操作计划会变复杂。

图12.8–12.9改用 Route 共同抽象:复合 Route 含有有序子 Route,Door Leg 与 Leg 是叶;各层都表示货箱从一地到另一地的移动。客户端可统一请求 portOperations(),复合节点聚合子节点结果。该图只表达作者的模型方案,不是已验证的生产实现。

结构图:

classDiagram
    class Route {
      +portOperations() List
    }
    class CompositeRoute {
      +children Ordered~Route~
    }
    class DoorLeg
    class Leg
    Route <|-- CompositeRoute
    Route <|-- DoorLeg
    Route <|-- Leg
    CompositeRoute o-- "*" Route : 有序部分
这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 原书第12章|Composite · 查看原书依据

      Enter COMPOSITE. It would be nice, for certain clients, to treat the different levels in this construct uniformly, as routes made up of routes. Conceptually this view is sound. Every level of Route is a movement of a container from one point to another, all the way down to an individual leg. (See Figure 12.8.)

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第89章《Composite》(源文件:_epub-src/0321125215_ch12lev1sec2.html;单元02) - 结论依据:图12.3–12.9及原文展示从扁平Leg、专家分段、复杂类型图到Composite Route;各层同是货箱移动,操作计划遍历变简单。 - 原始内容:Enter COMPOSITE . It would be nice, for certain clients, to treat the different levels in this construct uniformly, as routes made up of routes. Conceptually this view is sound. Every level of Route is a movement of a container from one point to another, all the way down to an individual leg. (See Figure 12.8 .)