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

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

    Ten Pakistanis Among Unicorn Founders in America

    There are ten Pakistani immigrants included among founders or co-founders of unicorns in America, according to  a recent study by the National Foundation for American Policy (NFAP). A unicorn is a startup with a valuation of at least one billion U.S. dollars. Immigrant entrepreneurs of US unicorns are diverse, hailing from 76 different countries. India, with 96 companies, is the leading country of origin for the immigrant founders of U.S. billion-dollar companies. Immigrants…

    Continue

    Posted by Riaz Haq on June 8, 2026 at 6:00pm

    Growing Fan Base of Cockroach Janata Party in India

    "Indians live like cockroaches and die like cockroaches", argued Jayant Bhandari in an X post in April this year. "They vote for bottom of the barrel cockroaches as rulers, who rightly treat them as cockroaches", he added, faulting the people of India for this state of affairs. More recently, Indian Supreme Court Chief Justice Surya Kant said during a hearing that certain unemployed youth were "like cockroaches" who enter professions with fake degrees or become social media…

    Continue

    Posted by Riaz Haq on June 2, 2026 at 1:30pm — 6 Comments

    © 2026   Created by Riaz Haq.   Powered by

    Badges  |  Report an Issue  |  Terms of Service