Strategy Pattern VS Static Class

Oct 7 2011 11:06 AM
need someone professional help me get the difference beteen
 
first : 
 

static class SimpleMathOperations
{
public static double add(double a, double b) { return a + b; }
public static double subtract(double a, double b) { return a - b; }  
public static double multiply(double a, double b) { return a * b; }  
public static double divide(double a, double b) { return a / b; } } 

second : Implementing the strategy pattern
 

public interface IMathOperation { double PerformOperation(double A, double B); }
// ADD -----------------------------------------------
class AddOperation: IMathOperation
{
#region IMathOperation Members
public double PerformOperation(double A, double B)
{ return A + B; }

#endregion }
// Subtract -----------------------------------------------
class SubtractOperation: IMathOperation
{
#region IMathOperation Members

public double PerformOperation(double A, double B)
{ return A - B; }

#endregion }
// MULTILPY -----------------------------------------------

class MultiplyOperation: IMathOperation
{
#region IMathOperation Members public double PerformOperation(double A, double B) { return A * B; }

#endregion }
// DIVIDE -----------------------------------------------
class DivideOperation: IMathOperation
{ #region IMathOperation Members public double PerformOperation(double A, double B) { return A/B; } #endregion }  


I quoted strategy pattern from this website
http://www.c-sharpcorner.com/UploadFile/rmcochran/strategyPattern08072006095804AM/strategyPattern.aspx[^]

Answers (3)