The builder pattern and a large number of mandatory parameters

前端 未结 7 1948
甜味超标
甜味超标 2020-11-29 02:44

To date I use the following implementation of the builder pattern (as opposed to the implementation described here):

public class Widget {
    public static          


        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 03:05

    One advantage of the Builder Pattern that I rarely (if ever) see promoted is that it can also be used to conditionally construct the object, for instance only if all mandatory parameters are correct or if other required resources are available. In that respect they offer similar benefits to a static factory method.

提交回复
热议问题