java - Bulider Design Pattern to make generic method for methods having large number of parameters -
i have interface itest
, classa
& classb
implementing interface. testa
& testb
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
custom data types (related databases). simplified methods have more number of parameters.
i need make generic method in testab
in itest
interface , implement in both classes rather having own method.
testab(string a, string b, string c, d d, e e, f f, g g)
as number of parameters more, generic method testab
pain user has pass many null
values.
is usecase bulider design pattern?
if yes, how achieve using design pattern?
yep here use builder pattern. have objects holding information passed methods.
these objects created internal builder, while fields may hold default values. here small example how like.
paramtesta<d, e> parama = new paramtesta<>.builder(a, b, c).setd(d).sete(e).build(); testa(parama);
Comments
Post a Comment