NodeJs — Design Pattern — Build

Renan Deocleciano
2 min readApr 21, 2021

This article is part of my channel on Youtube. So, if you like share with your friends.

Build — What is this?

With the building pattern, you can build the object as needed. Imagine a fast food (Mac Donald’s) and you have some hamburgers, right?

Therefore, if you receive an order for three different hamburgers, you need to make a hamburger with the specifications. Such as: Double Cheese, Cheddar Bacon and Cheddar Chicken.

In the previous article, I wrote about the “Factory Pattern” and created a any scenario to illustrate the concept.

PS: If you don’t read, just click the link bellow:

Design Pattern — Factory

In this article, we will implement “the build” to generate the data according to the type of report requested.

So, let’s create our OrderBuild and then implement with the reports.

OrderBuild.js

Now, let’s add this build to the reports.

We must change some parts of old code to adapt our OrderBuild.

Company1:

That done, we did it! That’s how we can implement the Build Pattern with JavaScript!

If you liked it, just share it with your friends and don’t forget the like!!!

--

--