4 ms·
I agree that the example is easier to read with the single object param. It might be even easier to read using a fluent interface or a builder pattern. You shou
by mx-bojangles 2y ago
I agree that the example is easier to read with the single object param. It might be even easier to read using a fluent interface or a builder pattern. You should choose the best tool for the job.
As a counter-example, I prefer
setEnabled(item, true);
to
setEnabled({item: item, isEnabled: true});
- janalsncm 2y agoIf I have five parameters and they all need to be set (otherwise the object is invalid), think of a constructor as a sort of builder pattern that does all five at once and avoids checking for invalid states (e.g. you only set 3 of the variables) in other methods.