DEV Community

Discussion on: Builder Pattern

Collapse
 
drstruggle profile image
drstruggle

I have recently learned this builder pattern a little different... So this confuses me a bit.

My builder pattern went something like:
Vehicle myVehicle = new Vehicle.Builder().color("blue")
.doors(4).horsepower(140).make("make")
.model("model").price(122).type("type").Build();

So to me the crux was the fact that you can 'compose' a product via one build action.

Collapse
 
eidher profile image
eidher

Build methods are not exactly the builder pattern. However, implicitly is the same. Your code could be in the Director participant. You could use a public static Builder class with or without an interface and the build result is the Product, in your case Vehicle.