© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2021
V. SarcarSimple and Efficient Programming with C# https://doi.org/10.1007/978-1-4842-7322-7_8

8. Efficient Templates Using Hooks

Vaskaran Sarcar1  
(1)
Kolkata, West Bengal, India
 

This chapter will show you two important techniques. First, you’ll learn to use a template method. Why is this important? Template methods are one of the fundamental techniques for code reuse. Suppose you follow a multi-step algorithm to achieve a task. Using a template method, you can redefine some of these steps (but not all them) without altering their calling sequence.

This chapter starts with a demonstration that uses a template method. Later, you’ll use a hook method in addition ...

Get Simple and Efficient Programming with C#: Skills to Build Applications with Visual Studio and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.