fyodor-org-uk / fyodor

Fyodor is an open source Java library for generating random data
http://fyodor.org.uk
MIT License
15 stars 8 forks source link

Expressiveness #19

Open mogronalol opened 9 years ago

mogronalol commented 9 years ago

I noticed there is kind of a DSL like this:

RDG.list(RDG.integer()).next();

I wonder if stuff was reworded into a format like this it might be easier to follow:

//Add the generators to the generator interface, with the naming convention Generator.ofTs()
Generator<Integer> = Generator.ofLists(Generator.ofIntegers());

//Then the random class wouldn't return generators, it would return the result of Generator.next().  
//You'd then static import the RDG class aswell meaning you'd get something a bit more fluent
List<Integer> integers = randomList(ofIntegers())

This isn't actually my idea, it's something I got it from Karl a few months ago

karlwalsh commented 9 years ago

We have discussed this a few times actually, and each time we agreed to not change the api, at-least for now. I think the expressiveness is nice though, and it may be something we do in later versions, but possibly not for v2.

The randomList() example is also nice and we have also discussed this (I think Adolfo raised a similar issue too).

For now at-least, I think we should focus on a single entry-point into the library through RDG and see how it evolves before we make a decision.