2021年2月14日

组合模式(composite)

摘要: 使用组合模式的场景: 把部分与整体的关系有树形结构来表示,从而使客户可以使用统一的方式处理部分对象和整体对象 组合模式核心: 抽象构件(Component)角色:定义了叶子和容器构件的共同点 叶子(Leaf)构件角色:无子节点 容器(Composite)构件角色:有容器特征,可以包含子节点 使用组合 阅读全文

posted @ 2021-02-14 22:56 白衣风云 阅读(148) 评论(0) 推荐(0) 编辑

桥接模式(python)

摘要: from abc import ABCMeta, abstractmethod class Shape(metaclass=ABCMeta): def __init__(self, color): self.color = color @abstractmethod def draw(self): 阅读全文

posted @ 2021-02-14 00:44 白衣风云 阅读(63) 评论(0) 推荐(0) 编辑

导航