package
2.0.4
Repository: https://github.com/yuzp1996/studygolang.git
Documentation: pkg.go.dev

# README

模板方法模式

定义

在一个方法中定义方法的骨架,而将一些步骤延迟到子类中。模板方法可以让子类在不改变算法框架的基础上,重新定义算法的某些步骤

好处

方面老做法新做法
解耦性Coffee和Tea控制了一切waiter 和 Caffeinebeverage保护这一切算法
重复代码tea和coffee存在重复代码可以最大程度的复用
算法实现位置算法的知识和实现分散在很多的类中waiter 和 Caffeinebeverage专注于算法,子类提供具体实现

钩子

钩子是一种被声明在抽象类中的方法,但是只有空的或者默认的实现,钩子的实现可以让子类有能力对算法的不同点进行挂载。要不要挂钩,由子类决定

为了使用钩子,我们可以在子类中覆盖他,在这里,钩子控制了是否执行某些算法,也就是是否要加调料

好莱坞原则

(底层组件)别调用我们,(高层组件)我们会调用你们

允许底层组件将自己挂载到高层组件,但是由高层组件决定何时和如何使用这些组件

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author