I read this question on how to split large constructors in java. But I am not quite sure what I shall do in my case. The question suggests that a builder pattern is the better way to go but at the same time one person in some sub sentence said “only if some parameters are optional”. Because all my parameters are mandatory I don’t see any advantage of a builder pattern. I would only risk forgetting to pass an important peace of information. Is therefore my only option to create new logical grouped objects or am I missing some vital fact on the builder pattern? Builders only seem to be good if stuff can be missing?
Share
“Is therefore my only option to create new logical grouped objects or am I missing some vital fact on the builder pattern?”
My Opinion is :
Yes. Using builder in this case provides no additional benefit compared to the amount of work required in the abstraction.
Also mentioned in the comments: if you’ve got too many parameters for an object, maybe the object is doing too much.