Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

What is the difference between Builder design pattern and Factory design pattern?

Pragya Keshap answered on February 10, 2023 Popularity 5/10 Helpfulness 6/10

Contents


More Related Answers

  • What are the design-patterns used in Spring framework?
  • where design pattern factory is used
  • Factory Pattern
  • when to use builder pattern
  • When to use Factory Design
  • factory design pattern
  • factory design pattern
  • Sample Code for Builder Design Pattern
  • What are the examples of Builder design pattern in JDK?
  • When will you use Factory or Builder Design pattern?

  • What is the difference between Builder design pattern and Factory design pattern?

    1

    Both Factory and Builder patterns are creational design patterns.

    They are similar in nature but Factory pattern is a simplified generic

    version of Builder pattern.

    We use Factory pattern to create different concrete subtypes of an

    Object. The client of a Factory may not know the exact subtype. E.g.

    If we call createDrink() of a Factory, we may get Tea or Coffee

    drinks.

    We can also use Builder pattern to create different concrete

    subtypes of an object. But in the Builder pattern the composition of

    the object can be more complex. E.g. If we call createDrink() for

    Builder, we can getCappuccino Coffee with Vanilla Cream and

    Sugar, or we can get Latte Coffee with Splenda and milk cream.

    So a Builder can support creation of a large number of variants of

    an object. But a Factory can create a broader range of known

    subtypes of an object

    https://stalk-calvin.github.io/blog/2016/10/15/builder-pattern.html

    Popularity 5/10 Helpfulness 6/10 Language java
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Feb 10 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.