# 03. Template Method Pattern

![rw-book-cover](https://i.ytimg.com/vi/ZWipsgyNepo/maxresdefault.jpg)

## Metadata
- Author: [[Coding with Yalco]]
- Full Title: 03. Template Method Pattern
- Category: #articles
- URL: https://www.youtube.com/watch?v=ZWipsgyNepo
- Archive: https://web-archive.alecodes.page/bookmarks?bf=1&search=&title=03.%20Template%20Method%20Pattern
> [!tldr]
> #OODP #DesignPattern #ObjectOriented

This video covers the template method pattern. This pattern is used when executing predetermined steps in a certain order, and each step can be variably implemented. It illustrates a dining course at a French restaurant, emphasizing that, while various menu combinations are possible depending on the dishes provided at each stage, the order must be strictly adhered to.

Then, it explains the difference between abstract classes and interfaces, using the process of making hot beverages as an example, and reveals the 'Tea' and 'Coffee' classes that implement this process. These methods show that no matter how they are implemented, they are executed in order.

It also provides a more practical example using a program that reads files and saves them in a different format. Here, methods for loading files, checking formats, processing them according to the algorithm, and saving results are declared, and you can see them being conditionally executed by a template method called 'proce...

## Highlights
Template Method pattern.  This pattern is used when you need  to implement tasks that need to be   executed through certain predetermined steps. This pattern is useful when we need to ensure that   the whole process is executed in a specific order, although we can implement how we   perform each step in various ways. [View Highlight](https://read.readwise.io/read/01jafmhggcaetvx535rk5n49sz))

the Template Method pattern   can be useful in cases where the structure  of the algorithm to be implemented is fixed, 
but each detail process  can be changed or expanded. [View Highlight](https://read.readwise.io/read/01jafmpqsvvdkekx03v5nyvyny))

