I am learning about builder design pattern, I found two explanations of the same.
- With a static inner builder class which returns object of outer class appropriately.
- With One Builder Abstract class, then more than one implementations of the same and one director class.
I am totally confuse over which one it is? or is it both?
CodePudding user response:
It is both... and more. There are numerous patterns originating from different sources that are all referred to as "Builder". This is not so unusual as you might think; for example, there are numerous different patterns all referred to as "Factory" as well.
Regarding the two you mention.
- The static inner Builder was popularized by Josh Bloch in his book, Effective Java.
- The abstract polymorphic Builder was popularized by the GoF in their seminal Design Patterns book.
There are more useful Builder patterns from other sources as well. See: Builder isomorphisms.