Strategy Design Pattern in Laravel and PHP
Вставка
- Опубліковано 21 лип 2024
- Learn what the strategy pattern is and how it can be implemented using PHP in Laravel.
Socials:
/ nick_escobedo
#strategydesignpattern #php #laravel #designpatterns #designpatternsinphp - Наука та технологія
Very well explained. Thank you. I just finished reading about this in head first design patterns and wanted to see it in action.
I want more videos like this. This video is very useful 👌
Thank you!
Great work and great explanation it should be more practical like PayPal , Stripe and a credit/Debit Card. Thank you
Thanks for your comment and watching the video! I've used this pattern before with credit, Apple Pay, and Google Pay. It can also be used for Stripe and Paypal too good suggestion.
Great explanation and yes im interested in more Design patterns,
Awesome, I plan on creating more. Just released the factory design pattern a couple days ago.
thank you so much for this type of tutorial please continue with teaching other design patterns
Thank you for your kind words and support!
Very useful and very simple explaines. Thanks for the content
I appreciate the kind words!
Really great tutorial. I loved It. I implemented in my own way after watching your video. Thanks a lot. Please make more design pattern video tutorials for Laravel. Thanks in Advance.
Thank you, I will.
Awesome! Thanks a lot!
Thank you for the support!
Nice video. What is the difference between this and the factory design pattern?
Does not this violate the Open-Closed-Princiaple? Because every time a new method is added I have to go back to the constructor and add more?
Exactly.. PaymentStrategyContext constructor argument should be type of PaymentMethod interface
This also has a lot of similarities to the Registry Pattern, right? The Context class seems responsible for "registering" valid interface implementations. Are there any advantages or disadvantages to choosing one over the other?
I think you'll find among the various patterns that they all have similarities in some way. I haven't used the registry pattern, so I'm not sure at the moment.
Payment strategy context must getting object implemented payment interface and in context class need add method setNewPayment with input param payment interface, and in command we can set some strategy by default and change payment context with method setNewPayment
Is this whats also called the adapter pattern and facade patten? Or is there a nuance im missing?
No, Facade or Adapter is something entirely different. Having said that most design patterns share some common ideas I would say
Yes, completely agree. There are quite a few similarities among the design patterns, that's spot on!
Context versus Factory?
I find no difference between factory and this pattern