Peter_James
Peter_James

Reputation: 647

When should you not use the 'Builder Design Pattern' to create objects?

I was just curious if there was any time you would not use a 'Builder Design Pattern' to create objects.

Upvotes: 0

Views: 1752

Answers (2)

damat-perdigannat
damat-perdigannat

Reputation: 5950

I suggest you do not use builders when all your object's fields are required upon construction. In that case using a simple constructor might be enough, unless you see some other applicable creational patterns, such as factory or singleton.

Builders can also affect the size of your distribution. You may opt to not use the pattern when you don't want a bulk of classes, especially if you are distributing a library.

Object creation using builder patterns may also be replaced by using other languages or lambda (a feature in Java 8). In case, you prefer using those, then it would be alright for you to not use builders.

Upvotes: 1

Mina Tadros
Mina Tadros

Reputation: 634

The builder design pattern is used to create a complex object from simple ones step by step. If this is not your case, you should not use builder design pattern

Upvotes: 2

Related Questions