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

    Does Pakistan's Real GDP Exceed One Trillion US Dollars?

    A 2024 joint study of the International Labor Organization and the Small and Medium Enterprise Development Authority  (SMEDA) estimated Pakistan's undocumented economy at $457 billion. While other South Asian nations, particularly Bangladesh and India, do include estimated undocumented GDP figures in their official GDP, Pakistan's official GDP figures do not include such estimates. If the Pakistani government decides to include estimates of the informal economy in its official…

    Continue

    Posted by Riaz Haq on June 19, 2026 at 7:30am — 5 Comments

    Quantum Computing IPO Makes A British Pakistani Billionaire

    Ilyas Khan, the British Pakistan founder of Quantinuum, became a billionaire in the company’s IPO on NASDAQ last week. Khan is a pioneer in the revolutionary field of quantum computing which could speed up computing by orders of magnitude. It will have a huge impact in AI and encryption. Dr. Irfan Siddiqui, a Pakistani-American professor of Physics at University of California at Berkeley, is another top expert in quantum computing. …

    Continue

    Posted by Riaz Haq on June 12, 2026 at 10:00am — 4 Comments

    © 2026   Created by Riaz Haq.   Powered by

    Badges  |  Report an Issue  |  Terms of Service