Discrete Mathematics
Strategy uses composition rather than inheritance
Type of sort used in Arrays: Mergesort
The JFrame hook method that we overrode to print " I Rule "
The Template Method Pattern uses inheritance to defer implementation to other classes
Don ' t call us, we ' ll call you is known as the " Hollywood Principle "
A template method defines the steps of an algorithm
The template method is usually defined in an abstract class
Class tha likes web apps: applet
Optional algorithm steps are implemented by hook methods
Factory Method is a specialization of Template Method
The steps in the algorithm that must be supplied by the subclass are usually declared abstract
A method in the abstract supercalss that does nothing or privides default behavior is called a hook method
Big headed pattern: Strategy
The Arrays class implements its template method as a static method
OO原则:封装变化;多用组合,少用继承;针对接口编程,不针对实现编程;为交互对象之间的松耦合设计而努力;类应该对扩展
开放,对修改关闭;依赖抽象,不要依赖具体类;只和朋友交谈;别找我,我会找你。
模板方法模式:在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中。模板方法使得子类可以在不改变算法结构的情况
下,重新定义算法中的某些步骤。
钩子是一种方法,它在抽象类中不做事,或者只做默认的事情,子类可以选择要不要去覆盖它。
模板方法的抽象类可以定义具体方法、抽象方法和钩子。
Strategy uses composition rather than inheritance
Type of sort used in Arrays: Mergesort
The JFrame hook method that we overrode to print " I Rule "
The Template Method Pattern uses inheritance to defer implementation to other classes
Don ' t call us, we ' ll call you is known as the " Hollywood Principle "
A template method defines the steps of an algorithm
The template method is usually defined in an abstract class
Class tha likes web apps: applet
Optional algorithm steps are implemented by hook methods
Factory Method is a specialization of Template Method
The steps in the algorithm that must be supplied by the subclass are usually declared abstract
A method in the abstract supercalss that does nothing or privides default behavior is called a hook method
Big headed pattern: Strategy
The Arrays class implements its template method as a static method
OO原则:封装变化;多用组合,少用继承;针对接口编程,不针对实现编程;为交互对象之间的松耦合设计而努力;类应该对扩展
开放,对修改关闭;依赖抽象,不要依赖具体类;只和朋友交谈;别找我,我会找你。
模板方法模式:在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中。模板方法使得子类可以在不改变算法结构的情况
下,重新定义算法中的某些步骤。
钩子是一种方法,它在抽象类中不做事,或者只做默认的事情,子类可以选择要不要去覆盖它。
模板方法的抽象类可以定义具体方法、抽象方法和钩子。