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

    Iron Brothers China and Pakistan Celebrate 75 Years of "Unbreakable" Friendship

    President Xi Jinping and Prime Minister Shehbaz Sharif have met today in Beijing to reaffirm the "unbreakable" bond between their two "iron brother" countries on the 75th anniversary of the establishment of the China-Pakistan diplomatic ties. "No matter how the international landscape may evolve, China will always place priority on the development of China-Pakistan relations in its diplomacy with neighboring countries," he said. Over 7 decades of friendship witnessed Pakistan help…

    Continue

    Posted by Riaz Haq on May 25, 2026 at 8:30pm

    Pakistani-American Franchisee Joins Bid to Acquire Papa John's Pizza

    A Pakistan-American franchisee has joined a Qatari-backed investor group's bid to buy out the US-based Papa John's Pizza restaurants chain. Nadeem Bajwa started his part-time job in 1991 as a pizza delivery driver for Papa John's while attending college in Indiana. He has since risen to become the largest franchisee with nearly 300 restaurants across the United States. Bajwa's backing could help Irth, which is also backed by Brookfield Asset Management, in its $47 a share pursuit of…

    Continue

    Posted by Riaz Haq on May 18, 2026 at 10:00am

    © 2026   Created by Riaz Haq.   Powered by

    Badges  |  Report an Issue  |  Terms of Service