cloudant / sync-android

A JSON-based document datastore for Android applications
Apache License 2.0
267 stars 91 forks source link

v2.0 API discussion points #413

Closed tomblench closed 7 years ago

tomblench commented 7 years ago

Issue to track discussion points where we don't yet have a clear answer.

We should strike these off and/or open separate issues as and when we resolve what the next steps are for each.

rhyshort commented 7 years ago

With my arbitrary comparison

documentStore.database.create(revision);
documentStore.query.find(selector);

documentStore.database().create(revision);
documentStore.query().find(selector);

And after seeing our Mocks removed in #412, I think having database and query as methods (without the get prefix) is a nice compromise and allows us to do mocking without doing potential unsafe things to final fields via reflection.

So my vote is for .database() and .query().

ricellis commented 7 years ago

Should discuss whether these should be public:

ricellis commented 7 years ago

Added branch to change the NPE to IllegalArgumentException https://github.com/cloudant/sync-android/tree/413-npe-iae

ricellis commented 7 years ago

Other changes in branch https://github.com/cloudant/sync-android/tree/413-api-cleanup

brynh commented 7 years ago

I think I agree with most of the points except that com.cloudant.sync.replication.ReplicatorBuilder#withId is used in the setup of a replication policy by a user, so I think we need to keep it in the public builder. Its use is described in the replication policies guide

ricellis commented 7 years ago

@brynh thanks for the feedback. Regarding ReplicatorBuilder.withId() after further consideration I think it makes sense to leave it in place, since the alternative (for example passing the Replicator instance itself into the listener) requires exposing the Replicator which is much harder to do statically, and that makes the comparisons more difficult.

When looking at it however, I did notice a couple of other API issues in the replication policies:

wdyt?

brynh commented 7 years ago

@ricellis Yes, I agree that your suggestions make sense. Maybe as well to move SimpleReplicationCompleteListener from ReplicationService to ReplicationPolicyManager as well.