策略模式:我定义一个算法家族,并让这些算法可以互换。正因为每一个算法家族都被封装起来,所以客户可以轻易地使用不同的方法。
模版模式:定义一个算法的大纲,由子类决定其中某些步骤的内容。这样算法中的个别步骤可以有不同的实现细节,但是算法的结构依然维持不变。
|ˈstrætədʒi|
1. Strategy uses ____ rather than inheritance.
composition |ˌkɒmpəˈzɪʃn|
4. Type of sort used in Arrays.
merge sort |mɜːdʒ| v 合并、汇合
6. The Template Method Pattern uses ____ to defer implementation to other classes.
inheritance |ɪnˈherɪtəns| n 继承、遗传
defer |dɪˈfɜː(r)| v 推迟
8. Coffee and ____
tea
9. Don’t call us, we’ll call you is known as the ____ Principle.
hollywood
12. A template method defines the steps of an ____.
algorithm |ˈælgərɪðəm|
|ˈtʃæptə(r)|
13. In this chapter we gave you more ____.
caffeine |ˈkæfiːn|
14. The template method is usually defined in an ____ class.
abstract
2. ____ algorithm steps are implemented by hook methods.
optional |ˈɒpʃənl| adj 可选择的
3. Factory Method is a ____ of Template Method.
specialization |ˌspeʃəlaɪˈzeɪʃn, American -lɪˈz-| n 专门化、专业领域
7. The steps in the algorithm that must be supplied by the subclasses are usually declared ____.
abstract
|dɪˈkleə(r)| vt 宣告
9. A method in the abstract superclass that does nothing or provides default behavior is called a ____ method.
hook
10. Big headed pattern.
strategy
Big headed 自负 傲慢的
15. The Arrays class implements its template method as a ____ method.
static