lundi 17 janvier 2022

Which design pattern best suits for my scenario

I'm still junior into programming, and would like to use best practices for my current project.

  • I have checkout with checkout data.
  • Shipping will be calculated based on products (quantity, weight) and shipping address.
  • I have multiple shipping providers.
  • At first I want to use ShippingProvider 1 to calculate shipping price.
  • If shipping can't be calculated I want to use ShippingProvider 2
  • Again, if shipping can't be calculated I want to use ShippingProvider 3
  • At the end if none of the providers respond with shipping I want to use fixed shipping set in database.

I was thinking about Strategy pattern but in my case it can be run all of the strategies during checkout. Do you have any ideas how can be done in the correct way?

Aucun commentaire:

Enregistrer un commentaire