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

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

    PFX to Advance Pakistan Air Force Modernization

    Pakistan has unveiled its PFX (Pakistan Fighter Experimental) program as a significant upgrade to its JF-17 joint program with China. The new upgrade will have a number of stealth features ranging from the use of radar-absorbing composite materials and diverterless supersonic inlets (DSI) to internal weapons bay (IWB) which will significantly reduce the aircraft's radar signature. It is targeted for completion by the end of this decade. In addition, the PFX's twin-engine design will improve…

    Continue

    Posted by Riaz Haq on January 20, 2025 at 1:00pm — 1 Comment

    Pakistan to License Multiple LEO Satellite Internet Service Providers

    The Pakistan government is preparing to license three low-earth-orbit (LEO) satellite operators for space communication services in the country, according to media reports. The companies whose applications are pending include London-based OneWeb, China's Shanghai Spacecom and US headquartered Starlink.  They operate tens of thousands of small mass-produced satellites in low orbits that communicate with designated (mobile and stationary) ground stations.  Each LEO satellite circles the earth…

    Continue

    Posted by Riaz Haq on January 15, 2025 at 1:30pm — 2 Comments

    © 2025   Created by Riaz Haq.   Powered by

    Badges  |  Report an Issue  |  Terms of Service