Design Patterns: Strategy

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ก.ย. 2024
  • This is the second of an eight part series where Robert is joined by Phil Japikse to discuss design patterns. A design pattern is a best practice you can use in your code to solve a common problem. In this episode, Phil demonstrates the Strategy pattern. This pattern enables an algorithm's behavior to be selected at runtime.
    Resources:
    - Sample code: github.com/ski...
    - Design Patterns: Elements of Reusable Object-Oriented Software book: www.amazon.com...
    - Head First Design Patterns book: www.amazon.com...

ความคิดเห็น • 17

  • @fwd79
    @fwd79 5 ปีที่แล้ว +15

    Full list for this series:
    0. SOLID Design Patterns (start from here): th-cam.com/video/agkWYPUcLpg/w-d-xo.html
    1. Design Patterns: Command/Memento: th-cam.com/video/zRbHlDeon3E/w-d-xo.html
    2. Design Patterns: Strategy: th-cam.com/video/QZIvlny1Onk/w-d-xo.html
    3. Design Patterns: Template Method: th-cam.com/video/MfAvs0n9uMs/w-d-xo.html
    4. Design Patterns: Observer and Publish-Subscribe: th-cam.com/video/72bdaDl4KLM/w-d-xo.html
    5. Design Patterns: Singleton: th-cam.com/video/sbML3xFHRbI/w-d-xo.html
    6. Design Patterns: Factories: th-cam.com/video/JEk7B_GUErc/w-d-xo.html
    7. Design Patterns: Adapter and Façade: th-cam.com/video/XYa0rmRMZ1Q/w-d-xo.html
    8. Design Patterns: Decorator: th-cam.com/video/6PPMR0GWrZQ/w-d-xo.html

  • @master-azazel
    @master-azazel 3 ปีที่แล้ว +4

    such a great series. rewatching all of them before software architecture exam later this week

  • @sufianahmad7337
    @sufianahmad7337 4 ปีที่แล้ว +16

    I love the videos but I don't know why there is not a playlist for design patterns as I want a sequence to learn all the design patterns. Overall it helps a lot.

    • @Hasi29347
      @Hasi29347 3 ปีที่แล้ว +1

      th-cam.com/video/QZIvlny1Onk/w-d-xo.html&ab_channel=MicrosoftVisualStudio

  • @Jebusankel
    @Jebusankel 7 ปีที่แล้ว +9

    I thought the description of "changing behavior at runtime" was confusing because it just sounds like just regular conditional logic, like an if/else or switch. But the superhero example clarified it and especially the "do your thing" phrase. I would recommend just highlighting that the different strategies are being defined in a different place than they are being executed, whereas in simple conditional logic those are together.

    • @robotflynn1518
      @robotflynn1518 5 ปีที่แล้ว

      I think that is what 11:45 is about. The demo code doesn't really capture it, but they do talk about that fact several times. I agree it would be cool to have flashing letters to really drive the point home haha.

  • @danstoian7721
    @danstoian7721 ปีที่แล้ว

    I appreciate you guys so much for you work! It's good quality, yet simple! Good job!

  • @lingyongwang2817
    @lingyongwang2817 5 ปีที่แล้ว +3

    This is great. Thanks for sharing

  • @ВладимирНилов-в7ю
    @ВладимирНилов-в7ю 11 หลายเดือนก่อน

    How many accounts do you have? Or you trading from a single one? tell us pls

  • @sudippachal4262
    @sudippachal4262 หลายเดือนก่อน

    I have a doubt.
    We can achieve the same like below.
    IHero spiderMan = new SpiderMan();
    Assert.Equal(new WeaveWeb().ExercisePower(),spiderMan.DoHeroStuff());
    spiderMan = new SuperMan();
    Assert.Equal(new WeaveWeb().ExercisePower(),superMan.DoHeroStuff());
    spiderMan = new BatMan();
    Assert.Equal(new WeaveWeb().ExercisePower(),BatMan.DoHeroStuff());
    Then why do we need Strategy pattern. Please guide.

    • @nndd8585
      @nndd8585 23 วันที่ผ่านมา

      Because you want spiderMan (the initial object) to DoHeroStuff, and not a SuperMan. In other words, assigning SuperMan to spiderMan changes the original context that you want to operate on.

  • @randomusername982374
    @randomusername982374 7 ปีที่แล้ว +1

    Thanks so much!

  • @cyberclaim
    @cyberclaim 6 ปีที่แล้ว

    Guys that was hilarious! :) Loved it. Keep the good work!

  • @dzxxbj
    @dzxxbj 7 ปีที่แล้ว

    Can you provide the link of before video of this series?

  • @kesavanarayana6257
    @kesavanarayana6257 6 ปีที่แล้ว

    It very helpful if you can make video on dispatcher pattern

  • @j3bb9z
    @j3bb9z 4 ปีที่แล้ว

    I think a stateless example would be better.

  • @AdityaDodda
    @AdityaDodda 7 ปีที่แล้ว +6

    I have seen lot of playlists on TH-cam for design patterns. This is by far the least useful for developers. it is good if you are real amateur and and want the intro paragraph as a dialogue. Chapter 1 is never coming. Too much philosophical talk.