qala-io / datagen

Java lib that generates random data (numbers, strings, dates) - mostly to facilitate Randomized Testing.
http://qala.io/blog/randomized-testing.html
Apache License 2.0
60 stars 5 forks source link

StringModifier: turn into functional interface #19

Closed php-coder closed 5 years ago

php-coder commented 5 years ago

StringModifier can be turned into functional interface.

In order to do that, we should move implementation of modify(List<String>) method from WithDefaultBatchModify class into StringModifier and mark it as a default method.

ctapobep commented 5 years ago

The reason it was done with an abstract class is because the core lib is compiled and can be used with Java5+. We could drop support for Java5, but there should be at least some justification.

The idea behind a library like Datagen is that you don't clutter your test with low-level logic. Giving an ability to provide a lambda violates this principle. Moreover it's not an action that you want to pass - it's a result that you want to state, so lambdas barely suit here anyway. Instead of length(10).with((s) -> s.doSomeModifications()).english(10) you could write length(10).with(someModifications()).english(10) and make it more readable.

I recognize that this is not a strong argument, but I think arguments for both sides are pretty weak. So all in all I'm inclined to keep it as is for now.

php-coder commented 5 years ago

Ok, no problem. It was just an idea.

Do you support this library by the way?

ctapobep commented 5 years ago

I have plans to introduce changes (that you asked in other requests), add features. But right now I don't have enough time - maybe in 6 months things will change.