Answer the question
In order to leave comments, you need to log in
Why use the Builder pattern when you can pass an array to the constructor?
I read on resources that one of the reasons for using the Builder pattern is to create an object with a large number of parameters. But why not just use an array passed to the constructor for this?
Answer the question
In order to leave comments, you need to log in
Firstly, hinting, without looking into an absurdly long array, you can determine which fields are there by IDE auto-hinting, and not type them manually.
Secondly - OOP goodies, such as inheritance, for example, create a base object with most of the fields you need everywhere, and if necessary, expand and customize.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question