《设计模式解析》 第14章 设计模式的原则与策略 复习题
Review Questions
When it comes to choosing how to implement a design, what question should you ask? 该设计的主要关注点是什么?该设计的背景是什么?该设计的主要变化的地方? | |
What are five possible errors in using design patterns. Can you state them? 1、187页。 |
The "open-closed" principle says, "modules, methods, and classes should be open for extension while closed for modification." What does this mean? 模块,方法和类都应该能够对修改封闭:修改软件可能会引入新的问题,故尽可能的不要修改软件。 对扩展开放:能够应对变化的需求,能够方便加入新功能。 因此,合二为一就是:能够在不修改软件的情况下,扩展其功能。 | |
In what way does the Bridge pattern illustrate the open-closed principle? 桥模式中,在抽象类以及派生类中,使用具体实现的抽象进行操作,使得实现变化或者增加的时候,Abstraction 部分无需修改,就可以适应变化。 |
Even though a design pattern might give you insights into what could happen, you do not have to build your code to handle those possibilities. How do you decide which possibilities to handle now and which to be ready for in the future? 根据项目当前的需求,以及项目当前所处的背景进行分析,进而决断。 | |
Give a concrete example of the danger of misapplying a design pattern, based upon your current work |