Hi All!
I would like to start a code-style related discussion regarding how we
implement the builder pattern in the Flink project.
It would be the best to have a common approach, there are some aspects of
the pattern that come to my mind please feel free to add anything I missed:
1. Creating the builder objects:
a) Always create using static method in "built" class:
Here we should have naming guidelines: .builder(..) or
.xyzBuilder(...)
b) Always use builder class constructor
c) Mix: Again we should have some guidelines when to use which
I personally prefer option a) to always have a static method to create the
builder with static method names that end in builder.
2. Setting properties on the builder:
a) withSomething(...)
b) setSomething(...)
c) other
I don't really have a preference but either a or b for consistency.
3. Implementing the builder object:
a) Immutable -> Creates a new builder object after setting a property
b) Mutable -> Returns (this) after setting the property
I personally prefer the mutable version as it keeps the builder
implementation much simpler and it seems to be a very common way of doing
it.
What do you all think?
Regards,
Gyula