Rishi Prakash
Rishi Prakash

Reputation: 1779

What is the difference between Builder Pattern with static inner class and Builder design patterns with One Abstract and one+ concrete implimentations

I am learning about builder design pattern, I found two explanations of the same.

  1. With a static inner builder class which returns object of outer class appropriately.
  2. With One Builder Abstract class, then more than one implementations of the same and one director class. enter image description here

I am totally confuse over which one it is? or is it both?

Upvotes: 2

Views: 966

Answers (1)

jaco0646
jaco0646

Reputation: 17066

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.

  1. The static inner Builder was popularized by Josh Bloch in his book, Effective Java.
  2. 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.

Upvotes: 2

Related Questions