【Discrete Mathematics】Template Method Pattern

 
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原则:封装变化;多用组合,少用继承;针对接口编程,不针对实现编程;为交互对象之间的松耦合设计而努力;类应该对扩展
        开放,对修改关闭;依赖抽象,不要依赖具体类;只和朋友交谈;别找我,我会找你。
模板方法模式:在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中。模板方法使得子类可以在不改变算法结构的情况
        下,重新定义算法中的某些步骤。
钩子是一种方法,它在抽象类中不做事,或者只做默认的事情,子类可以选择要不要去覆盖它。
模板方法的抽象类可以定义具体方法、抽象方法和钩子。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值