-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Relax generic requirement on ClusterItem on clustering related interfaces #779
Comments
|
Relaxing the APIs for clustering to accept any object, rather than an object conforming to an interface defined in the library (like I definitely understand the constraints you are working with but as a library, we want to strike a balance between ease-of-use, safety, and also designing something familiar. |
Thanks for taking your time and considering my proposition.
Totally agree. Runtime error solution would be detrimental to quality of the library.
This is manageable even without runtime errors though. My proposition would be to enforce This solution hides this new implementation detail behind the factory and thus should not have any negative effect on ease-of-use, safety or familiarity. It just optionally shifts the function implementation from the model. Is this something you would be interested in? If you think this could be beneficial, or need some POC I can submit PR (or we can continue the debate here). If you are still convinced this isn't something the library would benefit from, please feel free to close this issue. Edit: Fix incorrect quote |
Can you comment here what the API changes would look like so we can get a picture of what you intend? Doesn't need to be a full PR with implementation, just what the interface changes would look like. |
Here is a gist with proposed changes.
Here is a example of using a getter instead of a function provided from an interface. Basically the idea is to provide a proof of existence of |
Thanks for the detailed gist you shared, I definitely have a clearer picture of what you mean now. To summarize, this API proposal enables clustering models that do not implement I'm certainly not against this change but my hesitation is that this is a breaking change and has implications (need to update our docs here on GitHub and on https://developers.google.com/maps/documentation/android-sdk/utility). Given that we just had a major version bump, this is something we can consider for the next major version change. If more people in the community feel strongly about this, we can reprioritize. |
This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you! |
Still valid |
This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you! |
Still valid |
This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you! |
Still valid |
Also valid feature request for me. Currently using wrapper |
This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you! |
Still valid. |
There is currently a PR adding clustering capability to android-maps-compose . Under the hood, this library is used as the implementation. |
I'm curious to know more about these concerns:
Have you seen evidence that this is actually slow? A wrapper object should be very lightweight, essentially just holding a reference to an object already on the heap. Fast to instantiate and takes very little memory. I think that's worth verifying with data before making a change like that. For both Java and Kotlin, it's idiomatic to pass objects that fit an interface that provides necessary info. It's less common to pass an arbitrary object and separately pass a function for looking up that info. I personally would argue it's more surprising. |
As a personal anecdote I've had a map with roughly 35000 markers. The app state was kept in a purely Kotlin module (multiplatform app), so it was not possible to persist the objects in the app state. We either had to recreate 35k of cluster items for each re-render, that was of course a huge performance hit, or keep a local state and synchronize it, making the whole process more complex and harder to maintain. It really felt like unnecessary complexity. If needed we can of course profile both solutions. But I'd argue that performance is not the only factor here.
For Java I agree.
For Kotlin I find this very common. As an example from stdlib you can see there are extension functions on
I'm not arguing for removal of |
This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you! |
not stale |
@wangela This issue is now more than 3 years old. Is there anything I can do to help this get moving? |
We'll take a look and re-evaluate in the coming weeks. |
Thanks for stopping by to let us know something could be better!
PLEASE READ
If you have a support contract with Google, please create an issue in the support console. This will ensure a timely response.
Discover additional support services for the Google Maps Platform, including developer communities, technical guidance, and expert support at the Google Maps Platform support resources page.
If your bug or feature request is not related to this particular library, please visit the Google Maps Platform issue trackers.
Check for answers on StackOverflow with the google-maps tag.
Is your feature request related to a problem? Please describe.
Currently the library requires you to implement
ClusterItem
on your data classes. This can be problematic when you don't own those classes and/or producers of the data (or just don't wan't your model to depend on this particular library).Describe alternatives you've considered
Creating wrapper implementing
ClusterItem
. This solution gets slow with large datasets/fast changing data. Additionaly it's just plain waste of memory.Describe the solution you'd like
Remove the
extends ClusterItem
from interfaces likeClusterRenderer
andAlgorithm
and thus in unopinionated manner enable other techniques of handling this problem.The text was updated successfully, but these errors were encountered: