Design Patterns · Junior · Question 15 of 75

When is the Builder pattern useful?

Explanation

Instead of a constructor with ten parameters - a chain new QueryBuilder().select('id').where(...).limit(10).build(). Examples: SQL query builders (Knex), URL and config builders. In JS, passing an options object is often enough.

Further reading

Problem with a question

Design Patterns · Junior · question 15

Test yourself

Take the Design Patterns · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz