Consider a builder when faced with many constructor

Static factories and constructors share a limitation: they do not scale well to large numbers of optional parameters. Traditionally, programmers have used the telescoping constructor pattern, in which you provide a constructor with only the required parameters, another with a single optional parameter, a third with two optional parameters, and so on, culminating in a constructor with all the optional parameter. We can use alternative when you’re faced with many optional parameters in a onstructor is the JavaBeans pattern, in which you call a parameterless constructor to create the object and then call setter methods to set each required parameter and each optional parameter of interest. This pattern has none of the disadvantages of the telescoping constructor pattern. Unfortunately, the JavaBeans pattern has serious disadvantages of its own. Because construction is split across multiple calls, a JavaBean may be in an inconsistent state partway through its construction. Luckily, there i...