jeudi 4 juin 2015

Bulider Design Pattern to make generic method for methods having large number of parameters

I have an interface Itest and ClassA & ClassB are implementing this interface. testA & testB are methods in these classes respectively.

testA(String a, String b, String c, D d, E e)

testB(String a, String b, String c, F f, G g) 

Here D, E, F, G are custom data types (related to databases). I simplified the methods actually they have more number of parameters.

I need to make a generic method in testAB in Itest interface and implement that in both classes rather than having their own method.

testAB(String a, String b, String c, D d, E e, F f, G g)

As the number of parameters is more, generic method testAB will be pain for the user as he has to pass so many null values.

  • Is this a usecase for Bulider Design Pattern?

  • If yes, how to achieve this using this design pattern?

Aucun commentaire:

Enregistrer un commentaire