Suppose that you have an object with many properties and you'd like to make it immutable for a couple of reasons. Comes the problem of constructing the object with a crazy constructor with too many parameters.
Let's say that this object has 20 properties, the following answers are quite innovative in the sense that they leverage method chain pattern, however, the resulting object is not immutable:
How many constructor arguments is too many?
Question:
How can one construct an immutable object with many properties without crazy constructors ?
(crazy: a constructor with too many parameters)
Aucun commentaire:
Enregistrer un commentaire