-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
1.x: Rename cache(int) to cacheWithInitialCapacity(int) #3498
Conversation
Hi. It is part of the public API and can't be just removed. In addition, why did you modify the underlying internal class? |
How about I modified the internal class because the only use of that constructor parameter was in the removed operator. If you'd prefer to deprecate, of course I'll revert that modification. |
We are kind of set for 1.1 in terms of API visibility. How about updating the javadoc and list alternatives? |
I've pointed developers directly at that javadoc, and they've still misunderstood the parameter. And that's best case! Any developer who just looks at the signature, which is most of them, misunderstands the parameter. Everyone assumes it's a bound on the buffer size, and it's so obvious that why would you read the javadoc? It'd be great to get this resolved in the 1.x series. |
Huge +1 to |
a67ae75
to
f29d7e9
Compare
Updated with rename, deprecation, and javadoc. |
@@ -3666,13 +3674,16 @@ public final Boolean call(T first, T second) { | |||
* <dt><b>Scheduler:</b></dt> | |||
* <dd>{@code cache} does not operate by default on a particular {@link Scheduler}.</dd> | |||
* </dl> | |||
* <p> | |||
* <em>Note:</em> The capacity hint is not an upper bound on cache size. For that, consider | |||
* {@link #replay(int)} in combination with {@link ConnectableObservable#autoConnect()} or similar. |
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.
👍
f29d7e9
to
ccbca40
Compare
👍 |
* | ||
* @param capacityHint hint for number of items to cache (for optimizing underlying data structure) | ||
* @return an Observable that, when first subscribed to, caches all of its items and notifications for the | ||
* benefit of subsequent subscribers | ||
* @see <a href="http://reactivex.io/documentation/operators/replay.html">ReactiveX operators documentation: Replay</a> | ||
*/ | ||
public final Observable<T> cache(int capacityHint) { | ||
public final Observable<T> cacheWithCapacityHint(int capacityHint) { |
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.
Looks good but can't decide if this alias requires Beta or Experimental or could stay plain.
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 inclination would be to leave it plain, since we're deprecating the original name.
It'd be great to see this rename carried into 2.x, or even see this form of the operator dropped altogether.
You can post a PR against 2.x where you can simply rename and no need for deprecation. |
@stealthcode, @abersnaze what's the situation among Netflix devs regarding this? |
ping Netflix team |
From what I can tell, this is a change to an existing public facing method name and that's a no-no for 1.x. @abersnaze is committing a change to the contributors.md that explains what changes are allowed in patch release, minor releases, and major releases. Method signatures of non-beta and non-experimental methods are only accepted in major version releases. You could mark both as deprecated and add a new method |
Well, that's what @loganj did in his PR :) No breaking changes, deprecation On Thu, Nov 19, 2015, 00:27 Aaron Tull [email protected] wrote:
@artem_zin |
Oh, I see. I misread the pull request. |
I don't see the source of the confusion. I suggest that we leave it alone in 1.x and rename it to |
A list is a data structure designed to grow. When you see Additionally, an initial size is not required to create an array list and it's a constructor parameter. Not only do you have to opt-in to using this non-default constructor overload, you would have to look at the documentation for any idea what the value is for. This is very different in that the size is required and it's a named method which should describe behavior but is misleading because of prior assumptions around the word "cache". |
@JakeWharton the If the term "cache" is not sufficient to indicate the contract then we should probably consider changing the name to one that does. What would be a better term for an operator that holds an ordered list of all events emitted from an observable to be replayed to all subscribers after the first? |
@stealthcode Hence the name |
To clarify: I don't really care what it's called in 2.x, as long as it's reasonably unambiguous (i.e., not |
@JakeWharton I think @stealthcode was agreeing that a new method name would make it clearer but not that I'm not very interested in spending a lot of energy bike shedding over the name so can we just have a vote for we want to do: (vote for as many options as you want in the order or preference) A) do nothing My vote is A, E, C, D, B. @loganj @stealthcode @akarnokd @JakeWharton @artem-zinnatullin. We'll tabulate the votes on Monday. |
My vote is A, E |
I vote E, A, C |
I vote B, D, A |
B. For 2.x I'd prefer to get rid of cache or replay and leave only one On Sat, Nov 21, 2015, 00:26 David Karnok [email protected] wrote:
@artem_zin |
I would like @JakeWharton votes but so far the A is the winner. |
B, C, D, E. presuming a change in 1.x means also making the change in 2.x. We have empirical evidence that the name and parameter are confusing to users. I can't imagine why we'd ignore that evidence based on our own lack of confusion. I also think it's funny that this balloting gives a single "do nothing" equal weight to four "do something" options. By my count, "do something" is winning even before my vote. |
B, C myself. I think it's just confusing and have been bitten by |
I vote B |
E&C then D&B then A On Fri, Nov 20, 2015, 7:16 PM Michael Bailey [email protected]
|
I think that E&C equate to to just C... (assuming that all api changes made in 1.x are carried over). |
B won and I'm fine with that. @loganj could do the honors of changing this PR to match. Just to be clear that means that |
Ping @loganj, let's do it! |
The parameter is a capacity hint, but more frequently confused with a buffer size like replay(int) than it is correctly understood. It also offers no guarantees, only the weak hope of optimization. This change renames the method, deprecating the old name. It also adds javadoc calling out that the parameter is not a bound and referencing replay(int).autoConnect() as a way to achieve that behavior.
ccbca40
to
bfe7412
Compare
Updated to specified naming. Apologies for the delay, was traveling on vacation. |
👍 |
1 similar comment
👍 |
1.x: Rename cache(int) to cacheWithInitialCapacity(int)
The parameter is a capacity hint, but more frequently confused with abuffer size like replay(int) than it is correctly understood. It also
offers no guarantees, only the weak hope of optimization.
The parameter is a capacity hint, but more frequently confused with a buffer size like replay(int) than it is correctly understood. It also offers no guarantees, only the weak hope of optimization.
This change renames the method, deprecating the old name. It also adds javadoc calling out that the parameter is not a bound and referencing replay(int).autoConnect() as a way to achieve that behavior.