Should we use one JSON object and pass it to the function, or should we pass several separated parameters?
One use case would be when submitting an HTML form using JavaScript, for example.
My guess is that when you have 20 values it's easier to handle one big object than 20 different parameters. Also I guess it's easier to maintain a function when you have one parameter, but it also means that you need to validate the object properties in the function when you are using a statically typed language. Since JavaScript is not a statically typed language, I don't see the benefice of using separated parameters (we will have to manually validate each parameter in the function anyway).
What are the pros and cons of both ways, and is there a recommended way?
Thanks.
Aucun commentaire:
Enregistrer un commentaire