JShell.setIdGenerator/setTempVariableNameGenerator

Paul Sandoz paul.sandoz at oracle.com
Thu Jul 23 17:11:51 UTC 2015


On 23 Jul 2015, at 18:38, Brian Goetz <brian.goetz at Oracle.COM> wrote:

>> 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.
> 

Yes, that’s often my experience when designing and using ‘em.


> (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.)
> 

+1.

Paul.


More information about the kulla-dev mailing list