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

Strategy Pattern

Post Series: Behavioral Design Pattern

This pattern allows a client to choose an algorithm from a family of algorithms at run-time and gives it a simple way to access it.

Strategy Design Pattern C#

  • Client: This is a class that contains a property to hold the reference of a Strategy object. This property will be set at run-time according to the algorithm that is required.
  • Strategy: This is an interface that is used by the Context object to call the algorithm defined by a ConcreteStrategy.
  • ConcreteStrategyA/B: These are classes that implements Strategy interface.

Implement

Example

Real Life Example of Strategy Design Pattern C#

When to use it?

  1. There are multiple strategies for a given problem and the selection criteria of a strategy is defined a run-time.
  2. Many related classes are only differ in their behaviors.
  3. The strategies use the data to which the client has no access.

Resource

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

https://viblo.asia/p/tim-hieu-strategy-pattern-znmMdy7YGr69

Leave a Reply

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

Back To Top