Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control over configuration and reasonable defaults #85

Closed
krzemin opened this issue Sep 9, 2018 · 1 comment
Closed

Control over configuration and reasonable defaults #85

krzemin opened this issue Sep 9, 2018 · 1 comment

Comments

@krzemin
Copy link
Member

krzemin commented Sep 9, 2018

So far we had only one configuration switch that controlled if we look up into default values when performing case class transformer expansion. By default we had this behavior turned on and the user had an ability do disable it using .disableDefaultValues dsl operation.

Considering recent contributions #80 and #81, we have 2 new flags that add some extra behavior around Java beans and optional values in target objects. And here comes the struggling whether they should be turn on by default, which of them and how we want to control the configuration in some wider scope.

One of the proposals would be to have them all turned off by default (that means change to current semantics!) and have the ability to turn them on with a single dsl operation.

sealed trait ExtraBehavior
case object DefaultValuesLookup extends ExtraBehavior
case object JavaBeansNaming extends ExtraBehavior
case object TargetOptionalDefaultsToNone extends ExtraBehavior

obj.into[Target]
  .enable(DefaultValuesLookup, JavaBeansNaming, TargetOptionalDefaultsToNone)
  .transform

// or even passed to `into`

obj.into[Target](enable(DefaultValues, Beans, OptionalDefaultsToNone))
  .transform

As this is breaking change, for least surprise, I would keep .disableDefaultValues in dsl that aborts the compilation with a message that informs about this is not needed any more and that other usages should be properly adjusted.

We could also think about separate configuration object that can be implicitly passed to .transformInto and .into which would allow pre-configuring the library in scope of the whole module or project, in case someone wants to have extras on by default without boilerplate.

@krzemin
Copy link
Member Author

krzemin commented Nov 21, 2018

It seems that idea of this DSL when flags are passed as vararg has disadvantage of being hard to discover from IDE. Let's stick to .enableXXX and .disableXXX for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant