Thursday, May 15, 2014

Builder Pattern in Java


Simple Note

(From wiki):
the intention of the builder pattern is to find a solution to the telescoping constructor anti-pattern. The telescoping constructor anti-pattern occurs when the increase of object constructor parameter combination leads to an exponential list of constructors. Instead of using numerous constructors, the builder pattern uses another object, a builder, that receives each initialization parameter step by step and then returns the resulting constructed object at once.

Program

https://github.com/benbai123/JSP_Servlet_Practice/tree/master/Practice/JAVA/DesignPattern/src/builder

Run TestMain.java to test.

Add base rice and lots of ingredients one by one to DonburiBuilder then build Donburi.

Reference:

Builder pattern

Grate answer at stackoverflow

Donburi

No comments:

Post a Comment