DEV Community

Discussion on: Using the Fluent Interface Pattern to Create JavaScript Objects

pclundaahl profile image
Patrick Charles-Lundaahl

I've never heard it called that before! I've always heard it referred to as the Builder Pattern. "Fluent" seems like a sensible name, though - you can use it for other things too (Knex, for example, uses it to build database queries).

I definitely find it really handy when there are a large number of optional elements, and also when the object in question is really complex.

I suppose the main downsides are 1) leaving your object in an unfinished state, and 2) perhaps making it harder to catch that at compile time (e.g., if you're using TypeScript or the like)?

Fantastic summary overall!