-
Notifications
You must be signed in to change notification settings - Fork 24
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
Deal with null QueryExpression and Projections in DataFindRequest better #74
Comments
@alechenninger is this still a concern? |
Can you still create requests in an invalid state? In other words, as a good design practice, I'd like to be able to create a request and see what is required from its constructor, and if something is omitted, it has a reasonable default. I don't want to find out I missed something vital only once I go to integration test it with a running lightblue API. My 2c |
I agree that a constructor shouldn't leave the object in an incomplete state (an issue I have with a lot of DI frameworks). I do like the expression style methods we currently have. So yeah, a builder would be the correct way to deal with this.
You shouldn't get a RuntimeException any more, but you will still get an exception from lightblue in the form of a LightblueResponseException.
|
I only suggested defaults as a fallback if you didn't make it explicit was required by a constructor or some other means. If requests are able to be created invalid still, then we should at least throw an exception client side for obvious problems rather than waiting for lightblue to respond with an error. That is, if you're missing a projection for a query where it is required, throw an error client side like, |
In other words, when I say failing at runtime is bad, it's only bad relative to failing at compile time. In other words Catching failure at compile time (via combination of constructor forcing arguments and/or defaults) > Catching failure at runtime client side > Catching failure at runtime lightblue side Waiting til it gets to lightblue is a bad time to find out you have an otherwise detectable bug in your query code basically. |
Can I +1 this? #257 happened to me because I can construct invalid queries. As someone who has been working with LB for about a week now, I can say that a fluent builder that guaranteed a correct query would be fantastic. If you're not well-versed in the query syntax and internals there's plenty of rope out there with which it's easy to hang yourself. |
Few options:
As an aside, this is why the Builder pattern is much prefered than mutable objects:
So I guess I'm suggesting IMHO moving all of these requests to a builder pattern where the final object is immutable and guaranteed valid, but ultimately anything other than throwing an NPE would be nice.
The text was updated successfully, but these errors were encountered: