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: 62

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

    Humbled Modi Reaches Out to China After Trump Turns Hostile

    Prime Minister Narendra Modi appears to be shedding his Hindutva arrogance. He is reaching out to China after President Donald Trump and several top US administration officials have openly and repeatedly targeted India for harsh criticism over the purchase of Russian oil. Top American officials have accused India, particularly the billionaire friends of Mr. Modi, of “profiteering” from the Russian…

    Continue

    Posted by Riaz Haq on August 24, 2025 at 9:00am

    Miller vs Schiller: The Battle of the Lobbyists for India and Pakistan

    The Indian government has hired Jason Miller, a former Trump aide, to lobby for India in Washington, DC for a monthly sum of $150,000 per month. Pakistan has retained Keith Schiller, also a former Trump aide, for a monthly compensation of $50,000 to help Pakistan get favorable treatment by the Trump Administration. It shows that India is outspending Pakistan by 3 to 1 on lobbying in Washington, but it does not appear to be paying off for New Delhi. …

    Continue

    Posted by Riaz Haq on August 13, 2025 at 5:00pm

    © 2025   Created by Riaz Haq.   Powered by

    Badges  |  Report an Issue  |  Terms of Service