Showing posts with label strategy pattern. Show all posts
Showing posts with label strategy pattern. Show all posts

Wednesday, February 19, 2014

Difference between Events and Delegates

Events are basically actions raised by an object when some condition met.
Like In stock class there is a property named Limit, and it raised an notification when it reaches certain limit. This notification is done by events


Delegate is more generic term which is similar to a pointer to a function.
They are generally used as a input parameter. In particular they are perfect way to implement Strategy pattern. For example, if I want to sort a List of objects, I can provide a Compare strategy to the method to tell the implementation how to compare two objects.


Thursday, June 6, 2013

Strategy Pattern

To describe the strategy pattern, lets take an example of Football game.
The specific design problem is,
       when game is in progress any team can change its strategy from defend to attack or vice-          
       versa.

The solution for the same is strategy pattern.
         We need to let the algorithm vary independently from clients that uses it.
Very soon I will update article with sample code and class diagram.