DEV Community

loading...

Discussion on: Becoming a better Laravel developer by using the SOLID design principles. Part 2

Collapse
connor11528 profile image
Connor Leech

Instead of using if-else there could be an array on the PaymentFactory class where the type maps to the class, like 'credit' => 'CreditCardPayment' and then instantiate the correct class based on the type. Definitely an opportunity for improvement by using constants here. That if-else is not so bueno imho. Thanks for the article! Looking forward to the rest :)

Thread Thread
abrardev99 profile image
Abrar Ahmad Author

Yes we can use this approach. As my examples are not perfect. There is a plenty of room for improvements.