Answer the question
In order to leave comments, you need to log in
What does pattern builder do compared to regular setters?
Object object = ObjectBuilder
.newObject()
.withA(a)
.withB(b)
.build();
Object object = new Object();
object.setA(a);
object.setB(b);
Answer the question
In order to leave comments, you need to log in
To get started, you should refer to some source of information about this template. For example, to this .
Imagine a complex object that requires painstaking step-by-step initialization of many fields and nested objects. The initialization code for such objects is usually hidden inside a monstrous constructor with a dozen parameters. Or even worse, it is sprayed all over the client code.
For example, the fact that the builder does not assemble itself, but another object / s based on the constructed details
. And the setters simply mutate the object, in fact, the structure is bare with public properties.
One pattern, another structure - that's the difference
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question