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

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

    Modi's AI Spectacle: Chaos and Deception in New Delhi

    The India AI Impact Summit 2026, held at Bharat Mandapam in New Delhi, has been marred by chaos, confusion and deception. The events on the ground have produced unintended media headlines for India's Prime Minister Narendra Modi who wants to be seen as the "vishwaguru" (teacher of the world) in the field of artificial intelligence as well. First, there was massive chaos on the opening day, with long…

    Continue

    Posted by Riaz Haq on February 19, 2026 at 12:00pm — 10 Comments

    India-Pakistan Cricket Match: The Biggest Single Event in the World of Sports

    Why did Pakistan's decision to boycott the India-Pakistan match in solidarity with Bangladesh in this year's T20 World Cup send shockwaves around the world? And why did it trigger the International Cricket Council's and other cricket boards' urgent efforts to persuade Pakistan to return to the match? The reason has a lot to do with its massive financial impact, estimated to be as much as …

    Continue

    Posted by Riaz Haq on February 11, 2026 at 4:00pm — 2 Comments

    © 2026   Created by Riaz Haq.   Powered by

    Badges  |  Report an Issue  |  Terms of Service