Advantage of Java Pattern where method takes Object as a parameter instead of individual parameters

倾然丶 夕夏残阳落幕 提交于 2019-12-05 16:02:56

Pros:

  1. If your method takes many parameters, using a parameter object makes the method signature sane.
  2. If you want to take additional parameters for the method later, using a parameter object means that you just have to add another field in the param object and the method signature need not change.
  3. If you want a batch version of the method, just pass a list of param objects.

Cons:

  1. Extra verbosity
  2. Another level of indirection
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!