JShell.setIdGenerator/setTempVariableNameGenerator

Brian Goetz brian.goetz at oracle.com
Thu Jul 23 16:38:37 UTC 2015


> I don't want two different ways to create an instance -- that adds unneeded complexity.  I don't want to blend the builder functionality into the dynamic functionality, that defeats the goal of separating out the functionality that is obscure, set-up related, and one-time from that that is state-bound and dynamic.
> 
> This is a tool API. The number of people who will have to type "new JShell.Builder().build()" in small.

I understand the argument, but the “express" version often does carry its weight.  The issue here is _discoverability_.  For the folks who just want an instance, they don’t have to learn about the builder and figure out when builder features they want; they can just invoke the simple static factory. (Having a static factory method whose spec just says “this is equivalent to…” doesn’t add a lot of complexity.)  Builders are great but they are often an extra concept that has to be navigated before you can do anything useful.  

(I also prefer a static factory for the builder; JShell.builder(), which can be a sibling to JShell.newInstance(), and that way the user doesn’t have to even utter the name of the builder abstraction.)  





More information about the kulla-dev mailing list