DEV Community

Discussion on: 4 Dangerous Problems in JavaScript Easily Solved by The Builder Design Pattern

tailcall profile image
Anton Istomin

As someone with a C background I can relate to this reasoning.

However in the end of the day, seeing that most resource heavy operations are DOM manipulations and network I/O, the costs for creating an extra builder class seem neglible compares to them.

Besides, big objects like that are created relatively rarely, so the overhead likely won't affect anything too much. And it's always possible to optimise if measurements show that this particular object takes too long to build.

Given the benefits of the builder pattern I can live with all of that. However I agree it's wise to use plain objects where possible, JS is tooled perfectly around them and in many cases its tools are just enough.