From the course: Node.js: Design Patterns

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Implementing a builder

Implementing a builder - Node.js Tutorial

From the course: Node.js: Design Patterns

Start my 1-month free trial

Implementing a builder

- [Instructor] In the last lesson, we took a look at how using a builder can improve our code by eliminating the telescoping constructor anti-pattern. In this lesson, we're actually going to construct the person builder class. So I'm currently within the exercise files under chapter two, chapter two lesson eight, and inside of the start folder I'm going to create a new file called PersonBuilder. And inside of this file we still want to construct people using the person class, so I'm going to include that class. So what we're going to do here is we're going to create a class called PersonBuilder, and we're going to make sure that we export this class. All right. So before we create the person builder, we actually have to modify the person class to use our builder. So I'm going to go into the person class, and what we're going to do here is, instead of having a bunch of arguments be sent to the constructor, we're going to send the constructor one object, and that object we're going to…

Contents