Define the algorithm skeleton in the operation, and delay some steps to the implementation of the subclass, so that a subclass can redefine the specific steps of the algorithm without changing the structure of the algorithm
Object
Abstract class: define abstract atomic operations (hook operations); implement a template method as the algorithm skeleton
Specific class: realize atomic operation
Applicable scene
Implement the invariant part of the algorithm in one go
The common behaviors in each subclass should be extracted and concentrated into a common parent class to avoid code duplication