Strategy Pattern
Upcoming SlideShare
Loading in...5
×
 

Strategy Pattern

on

  • 1,239 views

Strategy Pattern Explained

Strategy Pattern Explained

Statistics

Views

Total Views
1,239
Views on SlideShare
1,239
Embed Views
0

Actions

Likes
0
Downloads
15
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Strategy Pattern Strategy Pattern Presentation Transcript

    • Strategy Pattern Shahriar Iqbal Chowdhury Monjurul Habib Code Name: Remington http://www.facebook.com/groups/netter/
    • What is StrategyA plan of action or policy designed to achieve a major or overall aim.
    • Why Need Pattern for Strategy• The Strategy pattern is known as a behavioural pattern - its used to manage algorithms, relationships and responsibilities between objects.• The Strategy pattern is to be used where you want to choose the algorithm to use at runtime. A good use of the Strategy pattern would be saving files in different formats, running various sorting algorithms, or file compression
    • Strategy Pattern Says• Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it OR
    • Why, When and How?1. Allow a class to maintain a single purpose.2. Switch statement3. Adding a new implementation will cause a class file to be modified4. Create a class for each strategy5. Use a common interface for each strategy
    • Class Diagram
    • Pattern less Implementation
    • Context IStrategy
    • Concrete Strategy UPS Concrete Strategy USPS
    • WALL-E & Strategy Strategy : Capable to Identify Object Strategy : Identify and Recycle Garbage
    • Strategy : Identify Friend Strategy : Identify Girl Friend 
    • Strategy : Identify New Hope For Mankind
    • Strategy @.Net Framework• Array and ArrayList provide the capability to sort. Sort method will use the IComparable implementation for each element to handle the comparisons. Leaving the choice of comparison algorithm up to the user of the class like this is an example of the Strategy pattern.• The use of a Predicate<T> delegate in the FindAll<T> method lets the caller use any method as a filter for the List<T> so long as it takes the appropriate object type and returns a Boolean.
    • That’s It!!