Behavioral

Template Method

Defines the skeleton of an algorithm, letting subclasses fill in specific steps.

FrameworksData pipelinesTest fixtures

Understanding Template Method

The Template Method pattern defines the skeleton of an algorithm in a base class and lets subclasses override specific steps without changing the algorithm's structure.

How It Works

Base Class
Template
Subclasses
CSVMiner
overrides step2, step4
JSONMiner
overrides step2, step4
Base defines algorithm skeleton
1

Template Method

Base class defines algorithm skeleton.

1 / 4

Basic Implementation

Data mining with ETL template:

main.go
Loading editor...

Real-World Example: Game AI

Game AI with different strategies sharing common turn structure:

main.go
Loading editor...