Skip to content

Subscription.requestMore #21

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

Closed
benjchristensen opened this issue Apr 15, 2014 · 19 comments
Closed

Subscription.requestMore #21

benjchristensen opened this issue Apr 15, 2014 · 19 comments

Comments

@benjchristensen
Copy link
Contributor

Any particular reason for the "more" in requestMore?

public void requestMore(int elements);

It seems redundant to have "more", or non-applicable on the first invocation of it when nothing has yet been requested hence "more" is wrong.

Perhaps it's cleaner to just say:

public void request(int elements);
@viktorklang
Copy link
Contributor

Yeah, we thought about that at first, sadly it was too easy for people to think that you could "change your mind" by first doing "request(50)" and then "request(30)" and expect only 30 to be obeyed.

requestMore is extremely explicit about the expectations. Makes sense?

@benjchristensen
Copy link
Contributor Author

No it doesn't make sense. It is invalid to request "more" when nothing has yet been requested and having "more" does not communicate semantics of "change your mind" any better than "request" does. Once a request is submitted of course you can not "change your mind".

@viktorklang
Copy link
Contributor

Fair enough, how about requestNext(int numberOfElements)?

@benjchristensen
Copy link
Contributor Author

I just don't see why we need a suffix to "request". It comes across as unnecessary noise.

@viktorklang
Copy link
Contributor

@benjchristensen I'll make you a deal, let's just call it more :-)

@jbrisbin
Copy link

@benjchristensen @viktorklang this is why on the other issue I brought up the idea of hasMore(int) which seems to be apropos here.

I also am a little sketchy on the "request" part of the method name because that IMO implies a return value. Like I'm requesting a certain number of elements be returned to me, which is not what's happening.

@viktorklang
Copy link
Contributor

@jbrisbin It's not a question if it has more or not though. It's a signal of demand: "I request that you give me N elements"

What about demand(int elements) or perhaps onRequest(int elements)?

(As an aside, shouldn't we focus less of our energy on bikeshedding names and more on semantics :-) )

@jbrisbin
Copy link

@viktorklang names have importance because they should signal intent. The names should be the semantics as far as possible. So I understand the notion that names aren't important but I disagree: names are everything. :)

I get the the signal of demand thing. I just doubt that it's enough to make an informed decision about what to do if N elements aren't available. I fear the situation will be the same as blindly creating Iterators over empty collections which is simple to do in code but extremely expensive in practice while under load.

@rkuhn
Copy link
Member

rkuhn commented Apr 17, 2014

@jbrisbin I’m with you concerning clarity of naming and accordance with intent: what the method shall express is “signal additional demand for N units”, which is very clear. Shall we name it such?

BTW: I do not understand how empty collections enter the picture; sending demand has nothing to do with its fulfillment. It is rather unfortunate that there is such a big semantic gap between demand (n) and “to demand”. Unfortunately the alternatives are even worse—wish, desire, want, …

@viktorklang
Copy link
Contributor

@rkhun crave(int)? perhaps order(int)?

@DougLea
Copy link
Contributor

DougLea commented Apr 17, 2014

Or, just more(int)

(which I was about to suggest in one of my first posts before Viktor convinced me to stay out of bikeshedding...)

@viktorklang
Copy link
Contributor

@DougLea Haha, ok, so another one for more :-)

@rkuhn
Copy link
Member

rkuhn commented Apr 17, 2014

I’d have to disagree: request bears closer relationship to the desired meaning than more (which is quite an unusual method name ;-) ).

@DougLea
Copy link
Contributor

DougLea commented Apr 17, 2014

Apparently unusualness is what we want, to avoid misinterpretation.
Also, you'd pronounce more(1) as "more!", and more(2) as "more!!", and ...

@viktorklang
Copy link
Contributor

@DougLea There's also the opportunity for gimmeh with great-reading code like

gimmeh(5)

@JakeWharton
Copy link
Contributor

+1 to "more" being strange and to simplifying to just request.

@normanmaurer
Copy link
Member

I think I would also vote for request

@rkuhn
Copy link
Member

rkuhn commented Apr 24, 2014

summing up: three votes for request (Ben, Norman, myself) so far. @jbrisbin @smaldini @mariusaeriksen ?

@benjchristensen
Copy link
Contributor Author

This change is included in #40

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

No branches or pull requests

7 participants