2

I'm trying to understand Builder Pattern usages and to separate its usage types into groups. Here is what I discovered:

  • Builder can be used to provide immutability (avoiding telescoping) for an object it is building. So called Joshua Bloch's builder. So, we use builder to facilitate building an object with a lot of fields.

  • Builder can build some objects that need to be structured and follow some structure rules. For example XmlBuilder, that builds xml and can fail when wrong data is passed (e.g. not closing a tag, or so on). In this case builder validates inner object on each build step.

But what about GoF's builder? With Director, abstract Builder and different implementations... I have never seen such implementation in production. What is the relationship between Bloch's builder and the GoF builder? Are they truly related? What are the differences?

jaco0646
  • 15,303
  • 7
  • 59
  • 83
  • For the record: I think your question is "border-line" to being offtopic. – GhostCat Sep 11 '16 at 08:50
  • 1
    Josh Bloch states that his pattern, "is a form of the _Builder_ pattern" from the GoF. Personally, I don't see many similarities. Bloch's pattern is far more popular and is typically what people refer to when discussing a Builder. I have never seen a canonical GoF implementation in the wild. – jaco0646 Sep 11 '16 at 13:51
  • See the comment and answer from @[Fuhrmanator](http://stackoverflow.com/questions/27994474/do-we-need-a-build-method-in-the-builder-pattern/28026140#comment44436897_27994550) for a bit more detail on the GoF Builder. – jaco0646 Sep 12 '16 at 13:23
  • 1
    Possible duplicate of [What's the revised builder pattern?](https://stackoverflow.com/questions/4859815/whats-the-revised-builder-pattern) – Raman Sahasi Oct 30 '17 at 16:23

1 Answers1

0

I think that Bloch's builder pattern an GoF's builder pattern are two different patterns. I saw on some training, that Bloch's builder pattern was called an assembler pattern. But I suggest not to bother with finding similarities but just treat it as a mess in naming and always precise which builder pattern do you mean.

Przemysław Różycki
  • 809
  • 2
  • 10
  • 21