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

    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

    Can Pakistan's JF-17 Become Developing World's Most Widely Deployed Fighter Jet?

    Worldwide demand for the JF-17 fighter jet, jointly developed by Pakistan Aeronautical Complex (PAC) and China’s Chengdu Aircraft Industry Group (CAIG), is surging. It is attracting buyers in Africa, Asia and the Middle East. At just $40 million a piece, it is a combat-proven flying machine with no western political strings attached. It has enormous potential as the lowest-cost 4.5…

    Continue

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

    © 2026   Created by Riaz Haq.   Powered by

    Badges  |  Report an Issue  |  Terms of Service