Enterprise Application Architecture with .NET Core
by Ganesan Senthilvel, Ovais Mehboob Ahmed Khan, Habib Qureshi
The template method pattern
The template method pattern basically defines the steps of an algorithm inside a class as a contract while deferring some of the steps (methods) to be implemented by the derived classes; hence, it primarily defines the structure via an abstract base class.
We will explain its implementation using an example in continuation of our sample for a GUI app we created earlier for the abstract factory pattern. In fact, within the same example app, we cover abstract factory, builder, and template method patterns.
In the abstract factory example, we presented the IUIAbsFactory interface and mentioned two of the possible implementations as DarkUIAbsFactory and LightUIAbsFactory concrete factory classes. Since the difference ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access