Strategy Design Pattern

Code is Here:

Best Design Patterns Book :

Here is my Strategy design patterns tutorial. You use this pattern if you need to dynamically change an algorithm used by an object at run time. Don’t worry, just watch the video and you’ll get it.

The pattern also allows you to eliminate code duplication. It separates behavior from super and subclasses. It is a super design pattern and is often the first one taught.






20 responses to “Strategy Design Pattern”

  1. FoxMcWeezer Avatar

    In the video, the Dog and Bird class initially set their flyingType by doing = new ItFlys() or = new CantFly(). Would using setFlyingType(new CantFly()) also work?

  2. KJ Sudarshan Avatar

    I never liked paying college fees, because I felt its not worth it. But for your videos, I voluntarily wish to. That is the degree of satisfaction I have. I can't thank you enough.

  3. ionox0 Avatar

    Would this be an example of Composition?

  4. Michael Stock Avatar

    Great video, thanks for sharing!

  5. Chinedu Dimonyeka Avatar

    Thank you so much. I really appreciate. Thank you.

  6. ANKIT THAKUR Avatar

    I have a question.
    User can create object of class "Animal" only.
    Animal a1 = new Animal.

    Now in this case, the variable flyingtype in Animal class is uninitialized. How should that be initialized (i.e what should be its default behaviour).

  7. ANKIT THAKUR Avatar

    One of the best Design Pattern book explained by one of the best orators !
    Keep up the good work.

  8. maurice swanenberg Avatar

    This is one of the first videos that explains something in a way i get it in just 11 mins. Thanks for this and i will definitely check out your other vids now =)

  9. qian zhao Avatar

    I think you should set flyingType as private in Animal class, and invoke setFlyingAbility() in constructor of sub-class.

  10. Kim Joseph Avatar

    Wow….. why cant all professors teach like this?

  11. Jin Izzraeel Avatar

    This DP is so powerful.

  12. Esice Cyclone Avatar

    So beautiful! Thank you!! =D

  13. Noman Chowdhury Avatar

    Wd be great if thers's a UML 2 tutorial from you too…

  14. Leon Lyu Avatar

    Awesome explanation with right intent and clear solution!
    I wonder how this video could be translated into my local language version so that 1.3billion people shall benefit

  15. Programming Avatar

    Mr Banas thank you for your video, your code and explanation i appreciate it (we all do). i have a further question: how is this different from inheriting and overriding behaviour from a parent class?

  16. Alin-Cristian Niculae Avatar

    Try this at 1.5 speed,, trust me, you will understand every word!

Leave a Reply

Your email address will not be published. Required fields are marked *