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

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

    Indian NSA Doval Urges Young Hindus to Take Revenge on Muslims

    In a recent speech to young Hindus in New Delhi, the Indian National Security Advisor Ajit Doval urged his audience to "avenge history". He talked about the looting and destruction of Hindu temples and many centuries humiliation suffered by Indians. Though he did not…

    Continue

    Posted by Riaz Haq on January 14, 2026 at 2:00pm

    Pakistan Household Survey HIES 2024-25 Raises More Questions Than It Answers

    Recently released HIES 2024-25 household integrated economic survey by Pakistan Bureau of Statistics (PBS)  raises more questions than it answers. For example, it shows that Pakistani households are buying lower amounts of basic food ingredients like wheat, meat and eggs in the last four years, implying that people are eating less to cover other expenses, like electricity and gas. But it doesn't explain why the households have reported significantly lower purchases of these items than…

    Continue

    Posted by Riaz Haq on January 6, 2026 at 5:00pm

    © 2026   Created by Riaz Haq.   Powered by

    Badges  |  Report an Issue  |  Terms of Service