Questions tagged [builder-pattern]
The builder-pattern tag has no summary.
61 questions
2 votes
1 answer
151 views
For N and NBuilder, should N be an instance variable of NBuilder, or all parameters of N be instance variables of NBuilder,finally new N() in build()?
As far as I know about builder pattern, for example, an object, Student: public class Student{ private String name; private int age; //setter and getter } to apply builder pattern to ...
5 votes
6 answers
3k 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 ...
0 votes
1 answer
135 views
How to create QueryBuilder to work with concurrent requests
I need assistance with the QueryBuilder that generates OData query. Following is my implementation and it approach has couple of issues If user forgets to SetRootTable then it will cause serious ...
3 votes
1 answer
277 views
GOF class diagram for Builder pattern appears to contradict its corresponding sequence diagram
In the Design Patterns: Elements of Reusable Object Oriented Software, the Gang of Four present the following canonical form for the Builder pattern: In Appendix B the following is mentioned ...
-1 votes
1 answer
237 views
How can I use builders for products with incompatible interfaces?
I am working on a program to automatically design heater units based on varying client specifications. The process for creating each heater is quite involved and requires multiple optional steps ...
4 votes
2 answers
939 views
Is it a code smell to have two different implementations of the builder design pattern, for the same model?
Shoutout to David Arno for teaching me about the builder design pattern via this thread! I have since used that pattern althroughout the code base to abstract out creating models from data stores, ...
5 votes
2 answers
472 views
GoF Builder Pattern Applicability
The book Design Patterns: Elements of Reusable Object-Oriented Software says to use the builder pattern when The algorithm for creating a complex object should be independent of the parts that make ...
2 votes
2 answers
1k views
Builder Pattern: Is there any advantage of having instance variables + product reference instead of just product reference?
Consider the product class: class Car { private String color; private String model_num; //getters and setters for the above fields } Consider builder class 1: class CarBuilder1 { private ...