Strategy Design Pattern in C#

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ธ.ค. 2024

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

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

    Thanks! That was really helpful. I recently took part in recruiting challenge that needed a strategy pattern, and it really is helpful this strategy.

  • @dagmawegebere8150
    @dagmawegebere8150 6 หลายเดือนก่อน +1

    are you free to help with my project now?

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

    InvoiceProvider obj = new InternalInvoiceProvider();
    obj.PrintInvoice();
    obj = new ExternalInvoiceProvider();
    obj.PrintInvoice();
    It will also execute two PrintInvoice method of two different class with single object, then why we have to follow all. Please explain, waiting for the reply

    • @net-programmer
      @net-programmer  4 หลายเดือนก่อน

      Using strategy pattern you don't have to reinitialize the obj variable. This may be required in some scenarios where you want to preserve the state of the object. See dofactory.com/net/strategy-design-pattern real world example.

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

      @@net-programmer I got the point that we are passing a different class name in the SetStrategy method of context class.But my question is that we can achieve desire output with the help of re-initialization, without any SetStrategy method of any context class.

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

    promo sm 🙃