DEV Community

Discussion on: Using the Strategy Pattern in Laravel

Collapse
 
zenphp profile image
Jason Murray

Would it be better practice to remove the selection logic from the ExchangeRatesServiceProvider class and move it into an ExchangeRatesProviderFactory class, just having the service provider instantiate the factory and then allow the factory to determine what to return?

Collapse
 
ashallendesign profile image
Ash Allen

Hi Jason, that's a very good question. To be totally honest, I'm not sure which of them is the better practice. But I think that both approaches would be more or less doing the same thing, so my initial guess would be that it would be up to personal preference 😄