Second, Java object-oriented (15) _ template method design pattern

2018-05-06

 

Template Method Design Pattern

 

Define the skeleton of the algorithm in an operation in a method of the parent class, while deferring some steps to the subclasses, since implementation details differ for different subclasses. Template methods allow subclasses to redefine certain steps of an algorithm without changing its structure.

 

Abstract parent class: define the business skeleton in the operation, and defer these steps to the subclass.

The abstract parent class provides at least two methods:

  1) Template method: A general processing method, namely template (the skeleton of the overall algorithm).

  2) Abstract method: A concrete business function implementation is completed by subclasses.

 

 

Reference: https://www.cnblogs.com/liaoweipeng/p/5790395.html

   https://blog.csdn.net/qq_25827845/article/details/51868973

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325348306&siteId=291194637