Are these both considered Builder pattern? They're extremely different and having different totally different implementations and purposes The 2019 Stack Overflow Developer Survey Results Are InWhat is the difference between Builder Design pattern and Factory Design pattern?Best method to remove session handled by Session Proxy patternA Bridge Pattern exampleHow to implement the factory method pattern in C++ correctlyEffective Java By Joshua Bloch: Item1 - Static Factory MethodInheriting a class which is built using a static inner class BuilderHow to implement Builder pattern in Kotlin?Singleton Design Pattern - Explicitly stating a Constructor outside the classWhich Design Pattern I need to Use Java Applicationembedded c++ : dynamic typing without dynamic allocation?
Are there any other methods to apply to solving simultaneous equations?
How to answer pointed "are you quitting" questioning when I don't want them to suspect
What is the best strategy for white in this position?
How to manage monthly salary
How to change the limits of integration
Inversion Puzzle
Why isn't airport relocation done gradually?
Landlord wants to switch my lease to a "Land contract" to "get back at the city"
What is the steepest angle that a canal can be traversable without locks?
"To split hairs" vs "To be pedantic"
It's possible to achieve negative score?
Extreme, unacceptable situation and I can't attend work tomorrow morning
Is bread bad for ducks?
CiviEvent: Public link for events of a specific type
What tool would a Roman-age civilization have to grind silver and other metals into dust?
Why is my p-value correlated to difference between means in two sample tests?
What is the use of option -o in the useradd command?
If a poisoned arrow's piercing damage is reduced to 0, do you still get poisoned?
Understanding the implication of what "well-defined" means for the operation in quotient group
Why could you hear an Amstrad CPC working?
What does "rabbited" mean/imply in this sentence?
Does light intensity oscillate really fast since it is a wave?
Inline version of a function returns different value than non-inline version
How can I fix this gap between bookcases I made?
Are these both considered Builder pattern? They're extremely different and having different totally different implementations and purposes
The 2019 Stack Overflow Developer Survey Results Are InWhat is the difference between Builder Design pattern and Factory Design pattern?Best method to remove session handled by Session Proxy patternA Bridge Pattern exampleHow to implement the factory method pattern in C++ correctlyEffective Java By Joshua Bloch: Item1 - Static Factory MethodInheriting a class which is built using a static inner class BuilderHow to implement Builder pattern in Kotlin?Singleton Design Pattern - Explicitly stating a Constructor outside the classWhich Design Pattern I need to Use Java Applicationembedded c++ : dynamic typing without dynamic allocation?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I've taken two Design Pattern courses now. 1 had this pattern below (note the lack of an interface).
class Coffee
private String name;
private int acidity;
private int sweetness;
private String roastType;
private int aromatic;
private String quality;
private int priceInDollarsPer100g;
public Coffee(Builder builder)
this.name = builder.name;
this.acidity = builder.acidity;
this.sweetness = builder.sweetness;
this.roastType = builder.roastType;
this.aromatic = builder.aromatic;
this.quality = builder.quality;
this.priceInDollarsPer100g = builder.priceInDollarsPer100g;
public static class Builder
private Builder builder;
private String name;
private int acidity;
private int sweetness;
private String roastType;
private int aromatic;
private String quality;
private int priceInDollarsPer100g;
// Only 1 field is mandatory
public Builder(String name)
this.name = name;
public Builder setAcidity(int acidity)
this.acidity = acidity;
return this;
public Builder setSweetness(int sweetness)
this.sweetness = sweetness;
return this;
public Builder setRoastType(String roastType)
this.roastType = roastType;
return this;
public Builder setAromatic(int aromatic)
this.aromatic = aromatic;
return this;
public Builder setQuality(String quality)
this.quality = quality;
return this;
public Builder setPriceInDollarsPer100g(int priceInDollarsPer100g)
this.priceInDollarsPer100g = priceInDollarsPer100g;
return this;
public Coffee build()
return new Coffee(this);
But in the next course there is no mention of this pattern at all. If I adapt it to the "interface/prescriptive/Static-product way", I get this:
package Builder.BuilderPattern2;
interface CoffeeAttributes
void setName(String name);
void setAcidity(int acidity);
void setSweetness(int sweetness);
void setRoastType(String roastType);
void setAromatic(int aromatic);
void setQuality(String quality);
void setPriceInDollarsPer100g(int priceInDollarsPer100g);
class Coffee implements CoffeeAttributes
private String name;
private int acidity;
private int sweetness;
private String roastType;
private int aromatic;
private String quality;
private int priceInDollarsPer100g;
public void setName(String name)
this.name = name;
public void setAcidity(int acidity)
this.acidity = acidity;
public void setSweetness(int sweetness)
this.sweetness = sweetness;
public void setRoastType(String roastType)
this.roastType = roastType;
public void setAromatic(int aromatic)
this.aromatic = aromatic;
public void setQuality(String quality)
this.quality = quality;
public void setPriceInDollarsPer100g(int priceInDollarsPer100g)
this.priceInDollarsPer100g = priceInDollarsPer100g;
interface CoffeeBuilder
public void buildName();
public void buildAcidity();
public void buildSweetness();
public void buildRoastType();
public void buildAromatic();
public void buildQuality();
public void buildPriceInDollarsPer100g();
public Coffee getCoffee();
class ZestyFrenchRoast implements CoffeeBuilder
private Coffee coffee;
public ZestyFrenchRoast()
this.coffee = new Coffee();
public void buildName()
this.coffee.setName("Zesty French Flave");
public void buildAcidity()
this.coffee.setAcidity(3);
public void buildSweetness()
this.coffee.setSweetness(10);
public void buildRoastType()
this.coffee.setRoastType("French");
public void buildAromatic()
this.coffee.setAromatic(7);
public void buildQuality()
this.coffee.setQuality("Medium");
public void buildPriceInDollarsPer100g()
this.coffee.setPriceInDollarsPer100g(3);
public Coffee getCoffee()
return this.coffee;
class CoffeeMaker
private CoffeeBuilder coffeeBuilder;
public CoffeeMaker(CoffeeBuilder coffeeBuilder)
this.coffeeBuilder = coffeeBuilder;
public Coffee getCoffee()
return this.coffeeBuilder.getCoffee();
public void makeCoffee()
this.coffeeBuilder.buildName();
this.coffeeBuilder.buildAcidity();
this.coffeeBuilder.buildAromatic();
this.coffeeBuilder.buildPriceInDollarsPer100g();
this.coffeeBuilder.buildQuality();
this.coffeeBuilder.buildRoastType();
this.coffeeBuilder.buildSweetness();
public class BuilderPattern2
public static void main(String[] args)
CoffeeBuilder coffeeToBuild = new ZestyFrenchRoast();
CoffeeMaker coffeeMaker = new CoffeeMaker(coffeeToBuild);
coffeeMaker.makeCoffee();
Coffee coffee = coffeeMaker.getCoffee();
System.out.println("The barista hands you a delicious cup of some kind of " +
"coffee but because there are no getters in this pattern we have no idea " +
"what it is. " + "Please pick it up at " + coffee);
RE: https://www.geeksforgeeks.org/builder-design-pattern/
There are no getters in the second version so obviously you wouldn't put text in the object, it would be a more abstract thing. I'm just at a loss to see these two patterns having the same name!
design-patterns
add a comment |
I've taken two Design Pattern courses now. 1 had this pattern below (note the lack of an interface).
class Coffee
private String name;
private int acidity;
private int sweetness;
private String roastType;
private int aromatic;
private String quality;
private int priceInDollarsPer100g;
public Coffee(Builder builder)
this.name = builder.name;
this.acidity = builder.acidity;
this.sweetness = builder.sweetness;
this.roastType = builder.roastType;
this.aromatic = builder.aromatic;
this.quality = builder.quality;
this.priceInDollarsPer100g = builder.priceInDollarsPer100g;
public static class Builder
private Builder builder;
private String name;
private int acidity;
private int sweetness;
private String roastType;
private int aromatic;
private String quality;
private int priceInDollarsPer100g;
// Only 1 field is mandatory
public Builder(String name)
this.name = name;
public Builder setAcidity(int acidity)
this.acidity = acidity;
return this;
public Builder setSweetness(int sweetness)
this.sweetness = sweetness;
return this;
public Builder setRoastType(String roastType)
this.roastType = roastType;
return this;
public Builder setAromatic(int aromatic)
this.aromatic = aromatic;
return this;
public Builder setQuality(String quality)
this.quality = quality;
return this;
public Builder setPriceInDollarsPer100g(int priceInDollarsPer100g)
this.priceInDollarsPer100g = priceInDollarsPer100g;
return this;
public Coffee build()
return new Coffee(this);
But in the next course there is no mention of this pattern at all. If I adapt it to the "interface/prescriptive/Static-product way", I get this:
package Builder.BuilderPattern2;
interface CoffeeAttributes
void setName(String name);
void setAcidity(int acidity);
void setSweetness(int sweetness);
void setRoastType(String roastType);
void setAromatic(int aromatic);
void setQuality(String quality);
void setPriceInDollarsPer100g(int priceInDollarsPer100g);
class Coffee implements CoffeeAttributes
private String name;
private int acidity;
private int sweetness;
private String roastType;
private int aromatic;
private String quality;
private int priceInDollarsPer100g;
public void setName(String name)
this.name = name;
public void setAcidity(int acidity)
this.acidity = acidity;
public void setSweetness(int sweetness)
this.sweetness = sweetness;
public void setRoastType(String roastType)
this.roastType = roastType;
public void setAromatic(int aromatic)
this.aromatic = aromatic;
public void setQuality(String quality)
this.quality = quality;
public void setPriceInDollarsPer100g(int priceInDollarsPer100g)
this.priceInDollarsPer100g = priceInDollarsPer100g;
interface CoffeeBuilder
public void buildName();
public void buildAcidity();
public void buildSweetness();
public void buildRoastType();
public void buildAromatic();
public void buildQuality();
public void buildPriceInDollarsPer100g();
public Coffee getCoffee();
class ZestyFrenchRoast implements CoffeeBuilder
private Coffee coffee;
public ZestyFrenchRoast()
this.coffee = new Coffee();
public void buildName()
this.coffee.setName("Zesty French Flave");
public void buildAcidity()
this.coffee.setAcidity(3);
public void buildSweetness()
this.coffee.setSweetness(10);
public void buildRoastType()
this.coffee.setRoastType("French");
public void buildAromatic()
this.coffee.setAromatic(7);
public void buildQuality()
this.coffee.setQuality("Medium");
public void buildPriceInDollarsPer100g()
this.coffee.setPriceInDollarsPer100g(3);
public Coffee getCoffee()
return this.coffee;
class CoffeeMaker
private CoffeeBuilder coffeeBuilder;
public CoffeeMaker(CoffeeBuilder coffeeBuilder)
this.coffeeBuilder = coffeeBuilder;
public Coffee getCoffee()
return this.coffeeBuilder.getCoffee();
public void makeCoffee()
this.coffeeBuilder.buildName();
this.coffeeBuilder.buildAcidity();
this.coffeeBuilder.buildAromatic();
this.coffeeBuilder.buildPriceInDollarsPer100g();
this.coffeeBuilder.buildQuality();
this.coffeeBuilder.buildRoastType();
this.coffeeBuilder.buildSweetness();
public class BuilderPattern2
public static void main(String[] args)
CoffeeBuilder coffeeToBuild = new ZestyFrenchRoast();
CoffeeMaker coffeeMaker = new CoffeeMaker(coffeeToBuild);
coffeeMaker.makeCoffee();
Coffee coffee = coffeeMaker.getCoffee();
System.out.println("The barista hands you a delicious cup of some kind of " +
"coffee but because there are no getters in this pattern we have no idea " +
"what it is. " + "Please pick it up at " + coffee);
RE: https://www.geeksforgeeks.org/builder-design-pattern/
There are no getters in the second version so obviously you wouldn't put text in the object, it would be a more abstract thing. I'm just at a loss to see these two patterns having the same name!
design-patterns
1
It depends what you are building I guess. Also the second half of your question seems missing
– Matthew Evans
Mar 8 at 7:49
@MatthewEvans Yeah I'm sorry about that. I'm working on that now, accidentally clicked Ask. 5 minutes
– Chrips
Mar 8 at 7:51
add a comment |
I've taken two Design Pattern courses now. 1 had this pattern below (note the lack of an interface).
class Coffee
private String name;
private int acidity;
private int sweetness;
private String roastType;
private int aromatic;
private String quality;
private int priceInDollarsPer100g;
public Coffee(Builder builder)
this.name = builder.name;
this.acidity = builder.acidity;
this.sweetness = builder.sweetness;
this.roastType = builder.roastType;
this.aromatic = builder.aromatic;
this.quality = builder.quality;
this.priceInDollarsPer100g = builder.priceInDollarsPer100g;
public static class Builder
private Builder builder;
private String name;
private int acidity;
private int sweetness;
private String roastType;
private int aromatic;
private String quality;
private int priceInDollarsPer100g;
// Only 1 field is mandatory
public Builder(String name)
this.name = name;
public Builder setAcidity(int acidity)
this.acidity = acidity;
return this;
public Builder setSweetness(int sweetness)
this.sweetness = sweetness;
return this;
public Builder setRoastType(String roastType)
this.roastType = roastType;
return this;
public Builder setAromatic(int aromatic)
this.aromatic = aromatic;
return this;
public Builder setQuality(String quality)
this.quality = quality;
return this;
public Builder setPriceInDollarsPer100g(int priceInDollarsPer100g)
this.priceInDollarsPer100g = priceInDollarsPer100g;
return this;
public Coffee build()
return new Coffee(this);
But in the next course there is no mention of this pattern at all. If I adapt it to the "interface/prescriptive/Static-product way", I get this:
package Builder.BuilderPattern2;
interface CoffeeAttributes
void setName(String name);
void setAcidity(int acidity);
void setSweetness(int sweetness);
void setRoastType(String roastType);
void setAromatic(int aromatic);
void setQuality(String quality);
void setPriceInDollarsPer100g(int priceInDollarsPer100g);
class Coffee implements CoffeeAttributes
private String name;
private int acidity;
private int sweetness;
private String roastType;
private int aromatic;
private String quality;
private int priceInDollarsPer100g;
public void setName(String name)
this.name = name;
public void setAcidity(int acidity)
this.acidity = acidity;
public void setSweetness(int sweetness)
this.sweetness = sweetness;
public void setRoastType(String roastType)
this.roastType = roastType;
public void setAromatic(int aromatic)
this.aromatic = aromatic;
public void setQuality(String quality)
this.quality = quality;
public void setPriceInDollarsPer100g(int priceInDollarsPer100g)
this.priceInDollarsPer100g = priceInDollarsPer100g;
interface CoffeeBuilder
public void buildName();
public void buildAcidity();
public void buildSweetness();
public void buildRoastType();
public void buildAromatic();
public void buildQuality();
public void buildPriceInDollarsPer100g();
public Coffee getCoffee();
class ZestyFrenchRoast implements CoffeeBuilder
private Coffee coffee;
public ZestyFrenchRoast()
this.coffee = new Coffee();
public void buildName()
this.coffee.setName("Zesty French Flave");
public void buildAcidity()
this.coffee.setAcidity(3);
public void buildSweetness()
this.coffee.setSweetness(10);
public void buildRoastType()
this.coffee.setRoastType("French");
public void buildAromatic()
this.coffee.setAromatic(7);
public void buildQuality()
this.coffee.setQuality("Medium");
public void buildPriceInDollarsPer100g()
this.coffee.setPriceInDollarsPer100g(3);
public Coffee getCoffee()
return this.coffee;
class CoffeeMaker
private CoffeeBuilder coffeeBuilder;
public CoffeeMaker(CoffeeBuilder coffeeBuilder)
this.coffeeBuilder = coffeeBuilder;
public Coffee getCoffee()
return this.coffeeBuilder.getCoffee();
public void makeCoffee()
this.coffeeBuilder.buildName();
this.coffeeBuilder.buildAcidity();
this.coffeeBuilder.buildAromatic();
this.coffeeBuilder.buildPriceInDollarsPer100g();
this.coffeeBuilder.buildQuality();
this.coffeeBuilder.buildRoastType();
this.coffeeBuilder.buildSweetness();
public class BuilderPattern2
public static void main(String[] args)
CoffeeBuilder coffeeToBuild = new ZestyFrenchRoast();
CoffeeMaker coffeeMaker = new CoffeeMaker(coffeeToBuild);
coffeeMaker.makeCoffee();
Coffee coffee = coffeeMaker.getCoffee();
System.out.println("The barista hands you a delicious cup of some kind of " +
"coffee but because there are no getters in this pattern we have no idea " +
"what it is. " + "Please pick it up at " + coffee);
RE: https://www.geeksforgeeks.org/builder-design-pattern/
There are no getters in the second version so obviously you wouldn't put text in the object, it would be a more abstract thing. I'm just at a loss to see these two patterns having the same name!
design-patterns
I've taken two Design Pattern courses now. 1 had this pattern below (note the lack of an interface).
class Coffee
private String name;
private int acidity;
private int sweetness;
private String roastType;
private int aromatic;
private String quality;
private int priceInDollarsPer100g;
public Coffee(Builder builder)
this.name = builder.name;
this.acidity = builder.acidity;
this.sweetness = builder.sweetness;
this.roastType = builder.roastType;
this.aromatic = builder.aromatic;
this.quality = builder.quality;
this.priceInDollarsPer100g = builder.priceInDollarsPer100g;
public static class Builder
private Builder builder;
private String name;
private int acidity;
private int sweetness;
private String roastType;
private int aromatic;
private String quality;
private int priceInDollarsPer100g;
// Only 1 field is mandatory
public Builder(String name)
this.name = name;
public Builder setAcidity(int acidity)
this.acidity = acidity;
return this;
public Builder setSweetness(int sweetness)
this.sweetness = sweetness;
return this;
public Builder setRoastType(String roastType)
this.roastType = roastType;
return this;
public Builder setAromatic(int aromatic)
this.aromatic = aromatic;
return this;
public Builder setQuality(String quality)
this.quality = quality;
return this;
public Builder setPriceInDollarsPer100g(int priceInDollarsPer100g)
this.priceInDollarsPer100g = priceInDollarsPer100g;
return this;
public Coffee build()
return new Coffee(this);
But in the next course there is no mention of this pattern at all. If I adapt it to the "interface/prescriptive/Static-product way", I get this:
package Builder.BuilderPattern2;
interface CoffeeAttributes
void setName(String name);
void setAcidity(int acidity);
void setSweetness(int sweetness);
void setRoastType(String roastType);
void setAromatic(int aromatic);
void setQuality(String quality);
void setPriceInDollarsPer100g(int priceInDollarsPer100g);
class Coffee implements CoffeeAttributes
private String name;
private int acidity;
private int sweetness;
private String roastType;
private int aromatic;
private String quality;
private int priceInDollarsPer100g;
public void setName(String name)
this.name = name;
public void setAcidity(int acidity)
this.acidity = acidity;
public void setSweetness(int sweetness)
this.sweetness = sweetness;
public void setRoastType(String roastType)
this.roastType = roastType;
public void setAromatic(int aromatic)
this.aromatic = aromatic;
public void setQuality(String quality)
this.quality = quality;
public void setPriceInDollarsPer100g(int priceInDollarsPer100g)
this.priceInDollarsPer100g = priceInDollarsPer100g;
interface CoffeeBuilder
public void buildName();
public void buildAcidity();
public void buildSweetness();
public void buildRoastType();
public void buildAromatic();
public void buildQuality();
public void buildPriceInDollarsPer100g();
public Coffee getCoffee();
class ZestyFrenchRoast implements CoffeeBuilder
private Coffee coffee;
public ZestyFrenchRoast()
this.coffee = new Coffee();
public void buildName()
this.coffee.setName("Zesty French Flave");
public void buildAcidity()
this.coffee.setAcidity(3);
public void buildSweetness()
this.coffee.setSweetness(10);
public void buildRoastType()
this.coffee.setRoastType("French");
public void buildAromatic()
this.coffee.setAromatic(7);
public void buildQuality()
this.coffee.setQuality("Medium");
public void buildPriceInDollarsPer100g()
this.coffee.setPriceInDollarsPer100g(3);
public Coffee getCoffee()
return this.coffee;
class CoffeeMaker
private CoffeeBuilder coffeeBuilder;
public CoffeeMaker(CoffeeBuilder coffeeBuilder)
this.coffeeBuilder = coffeeBuilder;
public Coffee getCoffee()
return this.coffeeBuilder.getCoffee();
public void makeCoffee()
this.coffeeBuilder.buildName();
this.coffeeBuilder.buildAcidity();
this.coffeeBuilder.buildAromatic();
this.coffeeBuilder.buildPriceInDollarsPer100g();
this.coffeeBuilder.buildQuality();
this.coffeeBuilder.buildRoastType();
this.coffeeBuilder.buildSweetness();
public class BuilderPattern2
public static void main(String[] args)
CoffeeBuilder coffeeToBuild = new ZestyFrenchRoast();
CoffeeMaker coffeeMaker = new CoffeeMaker(coffeeToBuild);
coffeeMaker.makeCoffee();
Coffee coffee = coffeeMaker.getCoffee();
System.out.println("The barista hands you a delicious cup of some kind of " +
"coffee but because there are no getters in this pattern we have no idea " +
"what it is. " + "Please pick it up at " + coffee);
RE: https://www.geeksforgeeks.org/builder-design-pattern/
There are no getters in the second version so obviously you wouldn't put text in the object, it would be a more abstract thing. I'm just at a loss to see these two patterns having the same name!
design-patterns
design-patterns
edited Mar 8 at 8:36
Chrips
asked Mar 8 at 7:46
ChripsChrips
1,39541525
1,39541525
1
It depends what you are building I guess. Also the second half of your question seems missing
– Matthew Evans
Mar 8 at 7:49
@MatthewEvans Yeah I'm sorry about that. I'm working on that now, accidentally clicked Ask. 5 minutes
– Chrips
Mar 8 at 7:51
add a comment |
1
It depends what you are building I guess. Also the second half of your question seems missing
– Matthew Evans
Mar 8 at 7:49
@MatthewEvans Yeah I'm sorry about that. I'm working on that now, accidentally clicked Ask. 5 minutes
– Chrips
Mar 8 at 7:51
1
1
It depends what you are building I guess. Also the second half of your question seems missing
– Matthew Evans
Mar 8 at 7:49
It depends what you are building I guess. Also the second half of your question seems missing
– Matthew Evans
Mar 8 at 7:49
@MatthewEvans Yeah I'm sorry about that. I'm working on that now, accidentally clicked Ask. 5 minutes
– Chrips
Mar 8 at 7:51
@MatthewEvans Yeah I'm sorry about that. I'm working on that now, accidentally clicked Ask. 5 minutes
– Chrips
Mar 8 at 7:51
add a comment |
1 Answer
1
active
oldest
votes
The first example shows the essential Builder Pattern. It can be used to avoid creating multiple constructors. If you sometimes need to add Name and Student ID, or other times you need to add Name, Address and Phone number, a single object Builder is very useful for that.
The second example is a Factory Builder!
It can be used to define priveleges for different kinds of users. These priveleges don't often change but vary among the types of users you have. That's where factory comes in.
Basically it's used to create a PRODUCT and that product does not often change.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058809%2fare-these-both-considered-builder-pattern-theyre-extremely-different-and-havin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The first example shows the essential Builder Pattern. It can be used to avoid creating multiple constructors. If you sometimes need to add Name and Student ID, or other times you need to add Name, Address and Phone number, a single object Builder is very useful for that.
The second example is a Factory Builder!
It can be used to define priveleges for different kinds of users. These priveleges don't often change but vary among the types of users you have. That's where factory comes in.
Basically it's used to create a PRODUCT and that product does not often change.
add a comment |
The first example shows the essential Builder Pattern. It can be used to avoid creating multiple constructors. If you sometimes need to add Name and Student ID, or other times you need to add Name, Address and Phone number, a single object Builder is very useful for that.
The second example is a Factory Builder!
It can be used to define priveleges for different kinds of users. These priveleges don't often change but vary among the types of users you have. That's where factory comes in.
Basically it's used to create a PRODUCT and that product does not often change.
add a comment |
The first example shows the essential Builder Pattern. It can be used to avoid creating multiple constructors. If you sometimes need to add Name and Student ID, or other times you need to add Name, Address and Phone number, a single object Builder is very useful for that.
The second example is a Factory Builder!
It can be used to define priveleges for different kinds of users. These priveleges don't often change but vary among the types of users you have. That's where factory comes in.
Basically it's used to create a PRODUCT and that product does not often change.
The first example shows the essential Builder Pattern. It can be used to avoid creating multiple constructors. If you sometimes need to add Name and Student ID, or other times you need to add Name, Address and Phone number, a single object Builder is very useful for that.
The second example is a Factory Builder!
It can be used to define priveleges for different kinds of users. These priveleges don't often change but vary among the types of users you have. That's where factory comes in.
Basically it's used to create a PRODUCT and that product does not often change.
edited Mar 8 at 8:53
answered Mar 8 at 8:46
ChripsChrips
1,39541525
1,39541525
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058809%2fare-these-both-considered-builder-pattern-theyre-extremely-different-and-havin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
It depends what you are building I guess. Also the second half of your question seems missing
– Matthew Evans
Mar 8 at 7:49
@MatthewEvans Yeah I'm sorry about that. I'm working on that now, accidentally clicked Ask. 5 minutes
– Chrips
Mar 8 at 7:51