-
Notifications
You must be signed in to change notification settings - Fork 2
use simple ADT to encode attribute values #27
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
Conversation
case class StringAttrValue(value: String) extends AttrValue | ||
case class BooleanAttrValue(value: Boolean) extends AttrValue | ||
|
||
implicit def stringToAttrValue(value: String): AttrValue = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is controversial but still seems to be quite common for such cases, see e.g., here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I think it goes to @cornerman's question in #14 (comment)
Do we consider this library directly user facing or is it more like a low level library powering, e.g., ff4s and outwatch.
If it's a low-level library, we probably wouldn't need this, right?
In general this looks good, but i am a bit concerned about allocations - introducing a wrapper for each attribute value. Does it have advantages over |
I hear you. I would prefer, however, not to use In any case, it would be great to have a set of benchmarks to be able to measure these things so that we can make an informed decision. |
I understand and totally agree that we need benchmarks for a good decision 👍 For me, I am actually using quite a lot of native types (like js array), because they should be quite optimized in today browsers - and served me well when measuring performance in a huge webapp developed with outwatch. |
Another strategy here, for keeping a friendly user API while avoiding allocations could be to use an encoding like Akka's Internally, we would have: class AttrValue(val v: String | Boolean) extends AnyVal and then expose the ADT "members" as |
A basis for discussion.