Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disadvantages of builder design pattern [closed]

What would be the disadvantages of using the builder design pattern. Are there any??

edit - I want to know whether there is any bad consequence of using builder design pattern? As in the GOF book, they have mentioned the good and bad consequences of design patterns. But they haven't mentioned any bad consequence for builder design pattern.

like image 261
agrawalankur Avatar asked May 13 '10 17:05

agrawalankur


People also ask

What are builder pattern disadvantages?

Disadvantages: 1) verbose and code duplication as Builder needs to copy all fields from Original or Item class. When to use Builder Design pattern in Java Builder Design pattern is a creational pattern and should be used when number of parameter required in constructor is more than manageable usually 4 or at most 5.

What are the consequences of applying the builder design pattern?

Here are key consequences of the Builder pattern: It lets you vary a product's internal representation. The Builder object provides the director with an abstract interface for constructing the product. The interface lets the builder hide the representation and internal structure of the product.

What is the advantage of builder pattern?

Advantages of the Builder pattern include: Allows you to vary a product's internal representation. Encapsulates code for construction and representation. Provides control over steps of construction process.

What are the disadvantages of applying GOF Singleton pattern?

They violate the single responsibility principle: by virtue of the fact that they control their own creation and lifecycle. They inherently cause code to be tightly coupled. This makes faking them out under test rather difficult in many cases. They carry state around for the lifetime of the application.


1 Answers

It does create more code (and could introduce more complexity) in the DTO than if you had for example contructor arguments and/or setters/getters.

In my opinion this is not a big deal, in most cases there is not a lot of extra code. The builder pattern will be more than worth it if you have an object that has some mandatory and some optional parameters.

like image 78
Jarle Hansen Avatar answered Sep 25 '22 19:09

Jarle Hansen