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

Rename Record "Value" to "Response" for consistency #44

Merged
merged 4 commits into from
Apr 8, 2019

Conversation

gino-m
Copy link
Collaborator

@gino-m gino-m commented Mar 31, 2019

Also, the meaning of "Value" is broad and conflicts with other symbols. This became apparent when implementing local db support because edits can refer to user responses but also changes to featute coordinates, for example.

Also, the meaning of "Value" is broad and conflicts with other symbols.
Copy link
Contributor

@scolsen scolsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! And looks good on the whole. I left a couple of comments on instances where value is still used in the binding term/variable even though Response is now the type. There's nothing wrong with this of course, but I think if we establish some symmetry between the two it establishes further that 'answer to a form element' == response, and it would signal the cases in which we're dealing with responses more strongly. Hopefully, that's not too pedantic--it's definitely a preferential thing so feel free to ignore (or correct me). I think clarifying it at the type level is clear enough.

String fieldId = field.getId();
Optional<Value> originalValue = r.getValue(fieldId);
Optional<Value> currentValue = getValue(fieldId).filter(v -> !v.isEmpty());
Optional<Response> originalValue = r.getValue(fieldId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/originalValue/originalResponse

@gino-m
Copy link
Collaborator Author

gino-m commented Apr 1, 2019

Pushed an update. PTAL!

Copy link
Contributor

@scolsen scolsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more small instances where we might want to change the text to Response, otherwise, lgtm!

@gino-m
Copy link
Collaborator Author

gino-m commented Apr 2, 2019

Caught a few more. Using "r" in lambdas, and "response" for variables. Also, renamed ambiguous and incorrect usages of "v ->" and "value ->".

@gino-m
Copy link
Collaborator Author

gino-m commented Apr 4, 2019

So... 🙄

Been thinking about this a bit more, and have an uncomfortable question to ask late in the review:

We will want a way to represent changed values in the edit queue both at Feature level (currently only for location, in the future probably custom id, and maybe even custom attributes), and Record level (currently only for form responses, but perhaps eventually for fixed attributes as well). In that case, rather than make Value more specific (record), perhaps we should be making it more generic by moving it out of Record, and letting it represent the allowed user-provided data types (String, Float, Array of Strings, Coordinates) rather than the allowed form element types (Text, Number, Multiple Choice)? We could then even use the same JSON representation in the local db's edit queue as in remote Firestore.

@navinsivakumar in case you have any amount of cents to add.

@scolsen
Copy link
Contributor

scolsen commented Apr 4, 2019

I just took a cursory look at the current definitions, so lmk if I'm misunderstanding here.

Sounds like a reasonable proposal. Just to make sure I'm getting it, essentially our Queue would take operations for any object that implements the value interface, which would enable us to stick pretty much whatever edits we want (feature, record, etc.) into the edit queue? That sounds like a good idea--I don't see any particular reason for needing distinct queues at the moment if we're trying to capture a sequence of operations on a set of entities, editBoo, editBah, etc.

I think that makes sense. So we'd have a rather general interface Value that defines the methods each editable object in the queue must implement, with further specifications for particular value types (sort of how it's setup in the record over form elements today). So Value, StringValue, FloatValue, etc. and Feature and Record can implement these as needed, and anything that implements them can be put into the edit queue?

As for the existing value interface, can we just call this FormElement, or FormField, or something equivalent?

@navinsivakumar
Copy link
Contributor

If we're looking at the data abstractions that are presented to application logic (which I think is what we have in this PR), I don't really see a case for trying to unify the Feature and Record value representations -- business logic of, say, a ViewModel, would never use them interchangeably, would it?

We might want to do something clever about unifying the representations further down the stack in the data layer, but I don't think that needs to be decided right now (or if it does need to be decided right now, then we're not enforcing the abstraction layers properly). My two cents is that it might be easier to treat them as separate at that level as well, although I am not familiar with how Firestore plays into this.

@gino-m
Copy link
Collaborator Author

gino-m commented Apr 5, 2019

I think this particular discussion might be off topic for the rename PR; moved to: #19 (comment)

@gino-m
Copy link
Collaborator Author

gino-m commented Apr 7, 2019

@navinsivakumar as per our other discussions, at the moment we won't use the Response for Features, so applying YAGNI here and leaving as is; we can refactor later if necessary.

Re reusing Value/Response in the local datastore, also agreed in the other thread that this would be bad practice for several reasons mentioned there.

@scolsen, sorry for the detour. Would you proceed with merge if you think it still looks ok?

@scolsen
Copy link
Contributor

scolsen commented Apr 8, 2019

You got it, merging!

@scolsen scolsen merged commit 09a1384 into google:master Apr 8, 2019
@gino-m gino-m deleted the rename-value-to-response branch June 29, 2019 20:28
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

Successfully merging this pull request may close these issues.

None yet

3 participants