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

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

3. 传统方案解决学校院系展示存在的问题分
将学院看做是学校的子类,系是学院的子类,这样实际上是站在组织大小来进行分层次的
实际上我们的要求是 :在一个页面中展示出学校的院系组成,一个学校有多个学院,一个学院有多个系, 因此这种方案,不能很好实现的管理的操作,比
边栏推荐
- GFS distributed file system
- Part III Verilog enterprise real topic of "Niuke brush Verilog"
- 时区的区别及go语言的time库
- XML configuration file (DTD detailed explanation)
- Tips for using pads router
- 4 points tell you the advantages of the combination of real-time chat and chat robots
- What are the functions of Yunna fixed assets management system?
- [EF core] mapping relationship between EF core and C data type
- 云呐|公司固定资产管理系统有哪些?
- VBA fast switching sheet
猜你喜欢

Detailed explanation of APP functions of door-to-door appointment service

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

认识提取与显示梅尔谱图的小实验(观察不同y_axis和x_axis的区别)

Qt QPushButton详解

用列錶初始化你的vector&&initializer_list簡介

如何让同步/刷新的图标(el-icon-refresh)旋转起来

Spreadjs 15.1 CN and spreadjs 15.1 en

Mathematical model Lotka Volterra

GFS分布式文件系统

20220703 week race: number of people who know the secret - dynamic rules (problem solution)
随机推荐
[binary search tree] add, delete, modify and query function code implementation
PV静态创建和动态创建
跟着CTF-wiki学pwn——ret2libc1
做自媒体影视短视频剪辑号,在哪儿下载素材?
Problems encountered in the database
4点告诉你实时聊天与聊天机器人组合的优势
传输层协议------UDP协议
数据库遇到的问题
[day39 literature extensive reading] a Bayesian perspective on magnetic estimation
shardingsphere源码解析
My colleagues quietly told me that flying Book notification can still play like this
Learn PWN from CTF wiki - ret2libc1
STM32__ 06 - single channel ADC
Effet Doppler (déplacement de fréquence Doppler)
Miaochai Weekly - 8
Breadth first search open turntable lock
[Luogu cf487e] tours (square tree) (tree chain dissection) (line segment tree)
微信小程序---WXML 模板语法(附带笔记文档)
Doppler effect (Doppler shift)
【luogu CF487E】Tourists(圆方树)(树链剖分)(线段树)