dynamo icon indicating copy to clipboard operation
dynamo copied to clipboard

Should the builder types be immutable?

Open guregu opened this issue 2 years ago • 0 comments

This is a question for v2.

Currently the builder types like *Query and *Update are mutable. This works similar to the standard library text/template package where they return themselves for convenience.

Some other packages (like goqu for example) use immutable types instead. The advantage of this method is that you can create base queries and easily extend them.

The disadvantage of switching is it would break any v1 code that relies on the mutability. Alternatively we could ditch the builder pattern. Functional parameters are the current best practice but we have a lot of disparate parameters so it would probably be annoying to work with 🤔

guregu avatar Feb 14 '23 11:02 guregu