Sunday, November 26, 2017

Nice Java Builder pattern example

Have to say I mostly use just the bean style setters and getters in the past, but came across this blog online:
It's really a neat explanation. I think in the future when we want to build immutable objects with optional fields, we should definitely use the builder pattern instead. I especially like the invariant checking part where the check is on the object fields rather than the builder fields, and make it thread safe.


Post a Comment

<< Home