The Builder pattern came up during a recent PR while looking at the standard Getter/Setter POJO pattern. I usually avoided the classic Builder pattern based on the necessity to duplicate the member variables in the static inner Builder class.
After some Googling and discussion we decided to use a slightly different Builder pattern. In
this version the base object is instantiated in the Builder constructor and simply returned
(and discarded) from the build()
function. This pattern allows for efficiently creating an