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

前端 未结 4 1338
清歌不尽
清歌不尽 2020-12-21 09:39

I have an interface Itest and ClassA & ClassB are implementing this interface. testA & testB are met

4条回答
  •  没有蜡笔的小新
    2020-12-21 09:58

    Yep here you could use the builder pattern. You would like to have objects holding the information passed to your methods.

    These objects could be created with an internal builder, while the fields may hold default values. Here a small example how this could look like.

    ParamTestA paramA = new ParamTestA<>.Builder(a, b, c).setD(d).setE(e).build();
    
    testA(paramA);
    

提交回复
热议问题