《设计模式解析》 第13章 用模式解决CADCAM问题 复习题

本文探讨了使用设计模式解决CAD/CAM问题的方法,包括软件设计的三个步骤:找出模式、分析和应用模式、添加细节。通过具体案例分析了上下文、最高模式、模式之间的关系以及在CAD/CAM问题中的应用。最后讨论了模式应用后的细节调整及快速原型设计的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

《设计模式解析》 第13章 用模式解决CADCAM问题 复习题

Review Questions

Observations

1:

What are the three steps of software design with patterns that the authors use?

1、找出模式

2、分析和应用模式:按北京的创造顺序将模式排序、选择模式并扩展设计、找到其他模式、重复

3、添加细节

2:

Define context.

一些 事物存在或发生所处的相互有关的情况——一种环境、一种场景。

3:

Define seniormost pattern.

最高模式为其他模式提供背景,约束其他的模式。

4:

When comparing two patterns, what are the two rules for discerning which pattern might be "seniormost"?

1、一个模式定义了另一个模式的行为?

2、有没有两个模式相互影响?

5:

Define generic structure of a pattern. When is it used?

Adapter:将一个接口转换为客户希望的另一个接口。使得原本由于接口不兼容而不能一起工作的类能够一起工作。(图略)

当我们需要将自己的设计转化为模式的标准形式时,使用它。

Interpretations

1:

Can a problem always be defined in terms of patterns? If not, what else is needed?

不能。需要有问题所考虑的关键部分,问题实体间的相互关系。

2:

In the CAD/CAM problem, the Abstract Factory was rejected as the "seniormost" pattern. What were the reasons for this?

规则:先考虑系统中需要什么,然后再去关注如何创建他们。

因此,关于创建的模式往往放在后面考虑,因而不会成为背景模式。

3:

In the CAD/CAM problem, what were the reasons for labeling Bridge as senior to Adapter?

1、Adapter用于解决不同版本的接口一致性问题。提供的接口是由桥模式中的实现部分去调用。因此,桥模式使用了适配器模式,故桥在适配器之前。

Opinions and Applications

1:

After all the patterns have been applied, there are still likely to be more details. Alexander's general rules (design by starting with the context) still apply. Does this ever stop? Is there ever a time when you should go ahead and dive into the details? Isn't that what "rapid prototyping" suggests? How can you avoid this temptation that all programmers have? Should you?

2:

Compare the first solution to the CAD/CAM problem (Figure 13-12) with the new version (Figure 13-11). What do you like better about the new design?

必然是新版本的解决方案。他使得整个项目更灵活,有更强的复用性。去除了许多不必要的冗余。并且Feature和ImpFeature各司其职,让内聚性更高。V1System无需直接访问多个Feature,只需使用抽象的Feature,使得耦合性更低。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值