mardi 25 avril 2017

Which is better for creating json request body: method with lots of arguments or builder pattern?

In my tests I send requests with such a body:

{
  "param": "value",
  "param": "value",
  "param": "value",
  "param": "value",
  "param": {
    "param": value,
    "param": "value"
  },
  "param": "value"
}

For each test I use different combination of values (params are always the same). So my question is which is better to use: a method with a bunch of arguments like

public JSONObject createRequestBody(param1, param2, param3, param4, param5, param6, param7) {...}

or a builder pattern? Or maybe there is another solution. Thanks!

Aucun commentaire:

Enregistrer un commentaire