Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat(core): integrate with Text Search API ordering #6001
feat(core): integrate with Text Search API ordering #6001
Changes from all commits
38dabf0
cdde113
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Now that the shape of the ordering lines up better with the params we send to the text search API, would it be better to remove this function and inline the logic?
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 don't see any strong reason to do so, but I'm happy to follow your advice 🙂. One advantage to
getOrder
being an individual function is that we can export it in order to unit test it (which we do).I've followed this same style for the prefix search integration (#6010), which is unit tested in the same way.
What do you think?
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.
My preference for inline-it vs abstraction boils down to how complex the abstraction is. My preference is to inline it if I find it easier to understand what's going on by reading the contents of the abstraction rather than reading the name of the function. This is more of an art than a science for sure.
Regarding testing, I prefer to unit test at a higher level if possible and try to preserve the behavior at that level. In this case, I would test the
createTextSearch
function as a whole and mock outclient.observable.request
and capture the params that were sent to it and expect it to match a certain value vs testing the smaller parts ofcreateTextSearch
.I kinda subscribe to the philosophy "write tests, not too many, mostly integration". I like this because if the implementation details change, the tests do not. However, this comes at the cost of the test itself being harder to write and requires more mocking.
At the end of the day this is an opinion and I'm not very dogmatic so feel free to merge 😇
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.
Thank you for explaining 🙏.
That's a great point. There's a (somewhat fuzzy) threshold of complexity at which the cognitive cost of context switching to the abstraction becomes lesser than the cost of reading the implementation inline. I think you're probably right about the threshold not being met in this case.
Another great point. I really love testing small units precisely because the tests are simpler to write.
createTextSearch
isn't tested at the moment—it probably should be—but we'd then be testing the same implementation at two different levels. That's not necessarily a problem, but I think you have a good point that it'd be better to simply invest in testingcreateTextSearch
itself in the first place.I think merging is probably the pragmatic thing to do, only because I'm not sure we get a lot of value from changing our approach at this stage. However, I do think these are great points, and they'll certainly shape how I work in the future 🙂. Depending on the time we have available, I may make tweaks here and request another review.