当前位置:网站首页>[designmode] composite mode

[designmode] composite mode

2022-07-06 00:00:00 weixin_ forty-three million two hundred and twenty-four thousan

Basic introduction

  1. Portfolio model (Composite Pattern), Also known as part of the overall model , It creates a tree structure of object groups , Combine objects into a tree structure to represent “ whole - part ” The hierarchy of .

  2. Combining patterns combine objects according to a tree structure , Used to represent part and whole level .

  3. This type of design pattern belongs to structural pattern .

  4. The combination mode makes the access of users to single object and combination object consistent , namely : Composition allows customers to deal with individual objects and composite objects in a consistent way

1. Look at the display needs of a school department

Write a program to show the structure of a school :

This is the demand , To show the composition of the school department in a page , There are many colleges in a school , A college has many departments . Pictured :

 Insert picture description here

2. Display of traditional solutions in schools and departments ( Class diagram )

 Insert picture description here

3. Traditional solutions to the problems existing in the display of schools and departments

  1. Think of the college as a subclass of the school , The Department is a subclass of the college , In fact, this is based on the size of the organization

  2. In fact, our request is : Show the composition of the school department in a page , There are many colleges in a school , A college has many departments , So this program , Management operations that cannot be well implemented , Than

原网站

版权声明
本文为[weixin_ forty-three million two hundred and twenty-four thousan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207052357214526.html