Dico
09/12/2018, 5:26 AMvar
if you want to do that. I would certainly recommend to keep the simple object immutable though! Consider adding default parameter values to the constructor of your class. That way, you can omit any properties you want to leave as the default.
Keep in mind that the JVM is very good at optimizing things like builder instantiation away. It can allocate it on the stack or skip instantiation altogether in some cases. In high throughput applications, the JVM beats all other languages once it's warmed up. If a task is performed very frequently, i.e. when performance matters, it will JIT the task, using statistics it collected earlier to determine how best to optimize the routine.