Strategy design pattern

Strategy pattern defines a family of algorithms, encapsulates each one, make them interchangeable. Strategy lets algorithms vary independently from clients that use it.

Strategy

Context is configured with strategy object. Maintains a reference to a strategy object. May defined an interface to access to strategy data.

public class Context<T>
{
	private IAbstractStrategy<T> _strategy;

	private Context(){}

	/// <summary>
	/// A context constructor which takes a concrete class 
	/// which implements algorithms
	/// </summary>
	/// <param name="strategy">A concrete class which implements algorithms to call</param>
	public Context(IAbstractStrategy<T> strategy)
	{
		_strategy = strategy;           
	}

	/// <summary>
	/// A member of the context class which is capable to use members of the concrete strategy class
	/// </summary>
	public T PerformAlgorithm(T param)
	{
		return _strategy.PerformAlgorithm(param);
	}
}

Strategy defines an interface common for all supported algorithms

/// <summary>
/// Defines an interface which have common methods to call by its context class
/// </summary>   
public interface IAbstractStrategy<T>
{
	T PerformAlgorithm(T param);
}

ConcreteStrategy implements the Strategy interface

/// <summary>
/// Concrete class which implements an interface defined by its contract
/// </summary>
public class ConcreteStrategy1<T> : IAbstractStrategy<T>
{
	public T PerformAlgorithm(T param)
	{
		return param;
	}
}