skip to Main Content

Welcome

Say hello to the toggle bar. This is an optional section you can use to display any content you'd like. Simply select a page from the theme panel and the content of the page will display here. You can even use the drag and drop builder to create this! This is a perfect place for your company mission statement, alerts, notices or anything else.

Get In Touch

Email: support@total.com
Phone: 1-800-Total-Theme
Address: Las Vegas, Nevada

Our Location

togglebar-map

Template Method Pattern

Post Series: Behavioral Design Pattern

This pattern is used to define the basic steps of an algorithm and allow the implementation of the individual steps to be changed. This pattern looks similar to the strategy design pattern. The main difference is the ability to change the parts of an algorithm rather than replacing an entire algorithm.

In Template pattern, an abstract class defined the template method and this method includes the steps which are implemented by the subclasses.

Template Method Design Pattern C#

  • AbstractClass: This is an abstract class that contains template method and abstract operations for each of the steps that may be implemented by subclasses.
  • ConcreteClassA/B: These are subclasses which inherits the AbstractClass and override the abstract class operations.

Implement

Example

Real Life Example of Template Method Design Pattern C#

When to use it?

  1. An abstract view of an algorithm is required, but implementation varies according to the subclasses.
  2. Common behaviors of subclasses can be used to make to a common class.

Resource

http://www.dotnettricks.com/learn/designpatterns/template-method-design-pattern-c-sharp

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top