mercredi 1 novembre 2017

Strategy pattern

I have to implement API for different clients. Implementation for each client will be different. So, I am thinking of using a strategy pattern in groovy(similar to Java) where I will have an interface and for each client I will create a class(which implements an interface) and I want to configure the class to be called using UI(dropdown selection for class) through an interface.

interface PricingStrategy {


}



class CanadaPricingStrategy implements PricingStrategy {

  Method 1...
  Method 2...

}

class BrazilPricingStrategy implements PricingStrategy {

  Method 1...
  Method 2...

}

Would it be the best way to do that or I can use pluggable-behaviour approach by using closure as a variable ?

Aucun commentaire:

Enregistrer un commentaire