Home > Enterprise >  What is the difference between Builder Pattern with static inner class and Builder design patterns w
What is the difference between Builder Pattern with static inner class and Builder design patterns w

Time:11-19

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?

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.

  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.

  • Related