All Questions
8 questions
5
votes
6
answers
2k
views
Is it a good idea to return a Builder from a Factory?
I would want to have a builder for creating a complex object, for example Employee.
I would want to be able to create my objects in two ways:
Case 1. Get Employee with default values
Case 2. Get ...
2
votes
2
answers
2k
views
Creational design pattern that allows configuration of objects
With the factory pattern we abstract the creation of objects. But what if we need a specific configuration of an object that depends on the calling context?
Example:
So I have a Builder pattern for ...
37
votes
9
answers
18k
views
Why do we need a Builder class when implementing a Builder pattern?
I have seen many implementations of the Builder pattern (mainly in Java). All of them have an entity class (let's say a Person class), and a builder class PersonBuilder. The builder "stacks" a variety ...
2
votes
2
answers
2k
views
Is it an antipattern to introduce complexity into a builder?
I've looked at various definitions of the builder pattern and whilst there's varying definitions, they tend to be focused on the broad definition of incremental construction. However, it seems that ...
5
votes
1
answer
15k
views
Is mixing Builders and Factory pattern a good idea?
I have an object Carconstructed using builder pattern.
Issue was a lot of code redundancy.
Car.Builder builder = new Car.Builder("Mercedes");
builder.numDoors(carConfig.getNumDoors()
...
14
votes
5
answers
11k
views
Is it strange for a Builder object to have getter methods?
I have a fairly complex immutable data type that I'm using a builder object to instantiate. Currently, I have a setup where I parse a file, setting various fields in my builder, and then build the ...
23
votes
5
answers
2k
views
Why would a type be coupled with its builder?
I've recently deleted a java answer of mine on Code Review, that started like this:
private Person(PersonBuilder builder) {
Stop. Red flag. A PersonBuilder would build a Person; it knows about a ...
2
votes
1
answer
6k
views
Intelligent builder pattern - different parameters depending on type - generics?
Lets say we have the famous Joshua Bloch Nutrition Builder and we want to change it so it be a bit like dynamic builder which restricts visibility of setters and propably uses generics :
public ...