Thank you for writing an interesting article! Especially on Java, there is not a lot of Java content on dev!
I have a question though, if the point of the interfaces here is to ensure that all the class fields are correctly set before build() is called, can you not just perform those checks in build()? Is it to force the check for this at compile time rather than run time?
The main idea is to shift checks back to compile time.
In general I'm trying to collect and organize new Java coding practices which will improve both development performance and code quality. The idea is to use various approaches to reduce mental overhead during development and let compiler help us write correct code. Mostly ideas are borrowed from functional programming, but sometimes this is just a conventions (for example like null handling approach described here) or interesting findings like one described in this article.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thank you for writing an interesting article! Especially on Java, there is not a lot of Java content on dev!
I have a question though, if the point of the interfaces here is to ensure that all the class fields are correctly set before
build()
is called, can you not just perform those checks inbuild()
? Is it to force the check for this at compile time rather than run time?The main idea is to shift checks back to compile time.
In general I'm trying to collect and organize new Java coding practices which will improve both development performance and code quality. The idea is to use various approaches to reduce mental overhead during development and let compiler help us write correct code. Mostly ideas are borrowed from functional programming, but sometimes this is just a conventions (for example like null handling approach described here) or interesting findings like one described in this article.