ok lets talk about Strategy Pattern.........

a) You have strategies=algorithms to solve a problem
b) context: every algoirhtm is suitable for a particular context
c) you invoke the strategy on the bases of context

example 1:

You can apply strategy pattern to dynamically change your basketball strategy during the game

Whats the context here?
skillset of players
time remaning
score
etc.

Whats the strategy here?
Basketball has strategies like 3-2-1, 2-1-2, 1-2-2

example 2:

You need to sort data in flat file

Whats the strategy here?

Merge sort
Radical sort
Quick Sort
etc

Whats the context?

Size of the file
data separability
etc.

Code:

http://www.dofactory.com/Patterns/PatternStrategy.aspx

Views: 52

Pre-Paid Legal


Twitter Feed

    follow me on Twitter

    Sponsored Links

    South Asia Investor Review
    Investor Information Blog

    Haq's Musings
    Riaz Haq's Current Affairs Blog

    Please Bookmark This Page!




    Blog Posts

    Global Baby Bust: Pakistan is A Rare Bright Spot Among Most Populous Nations in Asia

    There is an alarming rapid decline in fertility rates in both developed and developing nations, according to the United Nations.  Here is how the Wall Street Journal describes it: "The world is at a startling demographic milestone. Sometime soon, the global fertility rate will drop below the point needed to keep population constant. It may have already happened". …

    Continue

    Posted by Riaz Haq on May 14, 2024 at 9:31am

    India's Modi Brags About Ordering Transnational Assassinations

    In a campaign speech on May 1, Indian Prime Minister Narendra Modi bragged about his campaign of transnational assassinations of individuals he has labeled "terrorists". “Today, India doesn't send dossiers to the masters of terrorism, but gives them a dose and kills them on their home turf", he is reported to have said, according to a tweet posted by his BJP party. Last…

    Continue

    Posted by Riaz Haq on May 3, 2024 at 5:09pm — 2 Comments

    © 2024   Created by Riaz Haq.   Powered by

    Badges  |  Report an Issue  |  Terms of Service