当前位置:网站首页>【DesignMode】组合模式(composite mode)
【DesignMode】组合模式(composite mode)
2022-07-05 23:57:00 【weixin_43224306】
基本介绍
组合模式(Composite Pattern),又叫部分整体模式,它创建了对象组的树形结构,将对象组合成树状结构以表示“整体-部分”的层次关系。
组合模式依据树形结构来组合对象,用来表示部分以及整体层次。
这种类型的设计模式属于结构型模式。
组合模式使得用户对单个对象和组合对象的访问具有一致性,即:组合能让客户以一致的方式处理个别对象以及组合对象
1. 看一个学校院系展示需求
编写程序展示一个学校院系结构:
需求是这样,要在一个页面中展示出学校的院系组成,一个学校有多个学院,一个学院有多个系。如图:

2. 传统方案解决学校院系展示(类图)

3. 传统方案解决学校院系展示存在的问题分
将学院看做是学校的子类,系是学院的子类,这样实际上是站在组织大小来进行分层次的
实际上我们的要求是 :在一个页面中展示出学校的院系组成,一个学校有多个学院,一个学院有多个系, 因此这种方案,不能很好实现的管理的操作,比
边栏推荐
猜你喜欢

How to rotate the synchronized / refreshed icon (EL icon refresh)

关于结构体所占内存大小知识

Senparc.Weixin.Sample.MP源码剖析

Mathematical model Lotka Volterra

Fiddler Everywhere 3.2.1 Crack

After summarizing more than 800 kubectl aliases, I'm no longer afraid that I can't remember commands!

wx.getLocation(Object object)申请方法,最新版

GFS分布式文件系統

微信小程序---WXML 模板语法(附带笔记文档)

Configuring OSPF load sharing for Huawei devices
随机推荐
Teach you to run uni app with simulator on hbuilderx, conscience teaching!!!
亲测可用fiddler手机抓包配置代理后没有网络
4 points tell you the advantages of the combination of real-time chat and chat robots
Single merchant v4.4 has the same original intention and strength!
什么叫做信息安全?包含哪些内容?与网络安全有什么区别?
C # input how many cards are there in each of the four colors.
Online yaml to CSV tool
【luogu P3295】萌萌哒(并查集)(倍增)
【LeetCode】5. Valid palindrome
Rsync remote synchronization
Problem solving win10 quickly open ipynb file
Doppler effect (Doppler shift)
Zero rhino technology joined hands with the intelligence Club: the "causal faction" forum was successfully held, and the "causal revolution" brought the next generation of trusted AI
Research notes I software engineering and calculation volume II (Chapter 1-7)
俄外交部:日韩参加北约峰会影响亚洲安全稳定
CloudCompare&PCL 点云随机添加噪声
妙才周刊 - 8
提升工作效率工具:SQL批量生成工具思想
Transport layer protocol ----- UDP protocol
18. (ArcGIS API for JS) ArcGIS API for JS point collection (sketchviewmodel)