Giter VIP home page Giter VIP logo

Comments (6)

eli-darkly avatar eli-darkly commented on June 12, 2024

This has been proposed as a feature before, and the reason we haven't done it is that there's a conflict with the behavior of the analytics event system.

Specifically: when we report analytics for flag evaluations, we include not just the evaluated value, but also the default value. This shows up on your dashboard— so that you can see what value your applications are providing as a fallback in case flags aren't available, and adjust that in your code if you realize that it's not appropriate for that flag.

And that means that there isn't really such a thing as an evaluation where the SDK doesn't need to know the default value at all... which defeats the purpose of having something be lazily computed. The callback would always be called.

from java-server-sdk.

eli-darkly avatar eli-darkly commented on June 12, 2024

We did consider the option of simply not having the SDK report a default value if this feature is used, but at the time we felt that being able to see that value on the dashboard was a core feature.

from java-server-sdk.

swar8080 avatar swar8080 commented on June 12, 2024

That makes sense, thanks for the explanation. Feel free to close this

I was thinking of creating a wrapper around the client that takes a Supplier instead of a native java value, but then realized it'll break at runtime if the Supplier returns null. So another idea could be allowing null as a defaultValue in the SDK, but I'm assuming that has some bad tradeoffs

from java-server-sdk.

eli-darkly avatar eli-darkly commented on June 12, 2024

I was thinking of creating a wrapper around the client that takes a Supplier instead of a native java value

Could you say more about what that wrapper would actually do?

Again, the problem as I see it is that there is (currently) never a case in which the SDK doesn't use the default value parameter for something, even if it is only for analytics events. So if you tried to implement lazy computation of the default value using a Supplier, it wouldn't really be lazy; the Supplier would get called every single time.

Also, on rereading your original description of the issue, I'm not sure I understand your point about the current usage being "less readable". If you don't want to include a multi-line expression in your flag evaluation call, then you can simply move that logic into a helper method for computing the default value. That would be, as far as I can tell, 100% equivalent to what you're proposing with the Supplier— just a bit simpler.

from java-server-sdk.

swar8080 avatar swar8080 commented on June 12, 2024

Yeah I agree helper functions are good enough, although some might think it's nice to have the computation inline with a short lambda

Doesn't sound worth breaking the dashboard view you mentioned though

from java-server-sdk.

eli-darkly avatar eli-darkly commented on June 12, 2024

Well, maybe it's moot but I think I'm still missing your point. I mean - given that we can't really do lazy computation, the rationale would have to be that the syntax looks nicer. But if you're talking about a short lambda, then your original rationale of "it's less readable when there are multiple lines of computations" doesn't seem to apply. I mean, client.boolVariation(flagKey, user, () -> some kind of brief computation) looks almost exactly the same as client.boolVariation(flagKey, user, some kind of brief computation). Like, literally all you would be doing is adding () -> in front of the same expression.

If you do feel like discussing this further at all, I think an example of what you would want the usage to look like would be helpful.

from java-server-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.