Template Method Pattern in TypeScript

In the Template Method pattern, you create an abstract class (template) that contains a Template Method that is a series of instructions that are a combination of abstract and hook methods.

Abstract methods need to be overridden in the subclasses that extend the abstract (template) class.

Hook methods normally have empty bodies in the abstract class. Subclasses can optionally override the hook methods to create custom implementations.

So, what you have, is an abstract class, with several types of methods, being the…




A Design Pattern is a description or template that can be repeatedly applied to a commonly recurring problem in software design. A familiarity of Design Patterns is very useful when planning, discussing, managing and documenting your applications from now on and into the future.

Recommended from Medium

The JavaScript Spread Operator (…) — A Basic Guide

Simplest Way to connect your Smart Contracts to the Front-End(REACT) with Web3.js

Nullish coalescing operator (??)

Merge k Sorted Lists 🐫

Having fun with React Hooks

Laravel and VueJS: How do they complement each other?

JavaScript execution context part 1 — from compiling to execution

How to integrate React into an existing multi-page app

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sean Bradley

Sean Bradley

Developer of real time, low latency, high availability, asynchronous, multi threaded, remotely managed, fully automated and monitored solutions.

More from Medium

Visitor Pattern in TypeScript

How the TypeScript NonNullable Type Works

TypeScript Type Guards Using Reflect API

Scripting with a Type