某系统中的文本显示类(Text View)和图片显示类(Picture View)都继承了组件类(Component),分别显示文本和图片内容,现需要构造带有滚动条或者带有黑色边框,或者既有滚动条又有黑色边框的文本显示控件和图片显示控件,但希望最多只增加3个类。那么采用设计模式( )可实现该需求
- A.外观
- B.单体
- C.装饰
- D.模板方法
正确答案及解析
正确答案
解析
装饰(Decorator)模式可以再不修改对象外观和功能的情况下添加或者删除对象功能。它可以使用一种对客户端来说是透明的方法来修改对象的功能,也就是使用初始类的子类实例对初始对象进行授权。装饰模式还为对象动态地添加了额外的重任,这样就在不使用静态继承的情况下,为修改对象功能提供了灵活的选择。在以下情况中,应该使用装饰模式:想要在单个对象中动态并且透明地添加责任,而这样并不会影响其他对象;想要在以后可能要修改的对象中添加责任;当无法通过静态子类化实现扩展时。
包含此试题的试卷
你可能感兴趣的试题
Advancements in ( )have contributed to the growth of the automotive industry through the creation and evolution of self-driving vehicles.
-
- A.Artificial Intelligence
- B.Cloud Computing
- C.Internet of Things
- D.Big Data
- 查看答案
In project human resource management , ( )is not a source of power for the project manager.
-
- A.referent power
- B.expert power
- C.reward power
- D.audit power
- 查看答案
At the project establishment stage , the feasibility study mainly includes techinical feasibility analysis , ( ), operation environment feasibility analysis and other aspects of feasibility analysis.
-
- A.detail feasibility analysis
- B.opportunity analysis
- C.economic feasibility analysis
- D.risk analysis
- 查看答案
( )is a grid that shows the project resources assigned to each work package.
-
- A.Stakeholder engagement assessment matrix
- B.Requirements traceability matrix
- C.Probability and impact matrix
- D.Responsibility assignment matrix
- 查看答案
Xinhua News Agency reported in January 2022,Chian will further promote the developmet of a digital economy during the 14th Five-Year Plan eriod(2021-2025). The plan also emphasized industrial ( )transformation.
-
- A.digital
- B.networking
- C.intelligentize
- D.informatization
- 查看答案