Skip to content
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

SharedHashMap interface signatures #14

Closed
Cotton-Ben opened this issue Mar 4, 2014 · 25 comments
Closed

SharedHashMap interface signatures #14

Cotton-Ben opened this issue Mar 4, 2014 · 25 comments

Comments

@Cotton-Ben
Copy link

Do you think it might be a little clearer if the

 V acquireUsing(Object key, V value);

signature was changed to

 V getOrCreate(Object key, V value);  //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value);     //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for ( simple minded ) me the last one makes it easier to remember which signature can't return NULL. ;-)

@Cotton-Ben
Copy link
Author

 V getNonNullUsing(Object key, V value);     //even better?

@Cotton-Ben
Copy link
Author

I change me mind! I'm now familar with ...

V acquireUsing(Object key, V value);

let's keep it.

@peter-lawrey
Copy link
Owner

While not universally in computing, it think it is clear enough. I have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for (
simple minded ) me the last one makes it easier to remember which signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHubhttps://github.com//issues/14
.

@RobAustin
Copy link
Contributor

I was struggling to understand what acquireUsing() does, for me getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for (
simple minded ) me the last one makes it easier to remember which signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHubhttps://github.com//issues/14
.


Reply to this email directly or view it on GitHub.

@peter-lawrey
Copy link
Owner

The problem is that it doesn't strictly create anything either.
acquireUsing doesn't create any objects when used correctly, it is more
like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL
will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious non-NULL
will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for
(
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14>
.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36667028
.

@Cotton-Ben
Copy link
Author

I thought so too at first, but on second thought ... 'acquire' feels
more regal.

On 03/04/2014 02:59 PM, Rob Austin wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious
non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious
non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying
for (
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on
GitHubhttps://github.com//issues/14
.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#14 (comment).

@RobAustin
Copy link
Contributor

Some good java doc will help, Peter if you email me an explanation, I’ll add it to the code.

Rob

On 4 Mar 2014, at 20:08, Ben Cotton notifications@github.com wrote:

I thought so too at first, but on second thought ... 'acquire' feels
more regal.

On 03/04/2014 02:59 PM, Rob Austin wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious
non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious
non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying
for (
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on
GitHubhttps://github.com//issues/14
.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#14 (comment).


Reply to this email directly or view it on GitHub.

@peter-lawrey
Copy link
Owner

What you could do is treat remove(K, V) as replace(K,V, null) where the
replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either.
acquireUsing doesn't create any objects when used correctly, it is more
like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL
will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious
non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for
(
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14>
.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36667028
.

@peter-lawrey
Copy link
Owner

Do you think it makes sense to have a replaceReturnsNull(true) flag?

On 5 March 2014 10:00, Peter Lawrey peter.lawrey@gmail.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the
replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either.
acquireUsing doesn't create any objects when used correctly, it is more
like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I
have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL
will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious
non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying
for (
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14>
.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36667028
.

@RobAustin
Copy link
Contributor

Ok

Sent from my iPad

On 4 Mar 2014, at 23:00, Peter Lawrey notifications@github.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the
replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either.
acquireUsing doesn't create any objects when used correctly, it is more
like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL
will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious
non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for
(
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14>
.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36667028
.


Reply to this email directly or view it on GitHub.

@peter-lawrey
Copy link
Owner

Could you do a review of the methods implemented by AbstractMap to see
which ones we might want to override?

On 5 March 2014 10:01, Peter Lawrey peter.lawrey@gmail.com wrote:

Do you think it makes sense to have a replaceReturnsNull(true) flag?

On 5 March 2014 10:00, Peter Lawrey peter.lawrey@gmail.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the
replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either.
acquireUsing doesn't create any objects when used correctly, it is more
like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com
wrote:

While not universally in computing, it think it is clear enough. I
have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious
non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious
non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying
for (
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14>
.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36667028
.

@RobAustin
Copy link
Contributor

No - as before you do the replace you have to read() to see if a value exists so you do the read anyway.

Sent from my iPad

On 4 Mar 2014, at 23:01, Peter Lawrey notifications@github.com wrote:

Do you think it makes sense to have a replaceReturnsNull(true) flag?

On 5 March 2014 10:00, Peter Lawrey peter.lawrey@gmail.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the
replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either.
acquireUsing doesn't create any objects when used correctly, it is more
like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I
have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL
will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious
non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying
for (
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14>
.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36667028
.


Reply to this email directly or view it on GitHub.

@RobAustin
Copy link
Contributor

Sure - I'll raise some Jira's.

Sent from my iPad

On 4 Mar 2014, at 23:02, Peter Lawrey notifications@github.com wrote:

Could you do a review of the methods implemented by AbstractMap to see
which ones we might want to override?

On 5 March 2014 10:01, Peter Lawrey peter.lawrey@gmail.com wrote:

Do you think it makes sense to have a replaceReturnsNull(true) flag?

On 5 March 2014 10:00, Peter Lawrey peter.lawrey@gmail.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the
replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either.
acquireUsing doesn't create any objects when used correctly, it is more
like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com
wrote:

While not universally in computing, it think it is clear enough. I
have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious
non-NULL will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious
non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying
for (
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14>
.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36667028
.


Reply to this email directly or view it on GitHub.

@peter-lawrey
Copy link
Owner

Just for the record, acquireUsing, doesn't create any objects or use any
extra memory unless you pass null.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either.
acquireUsing doesn't create any objects when used correctly, it is more
like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL
will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious
non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for
(
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14>
.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36667028
.

@Cotton-Ben
Copy link
Author

Absolutely. I can see it being empowering ....

Sent from my iPhone

On Mar 4, 2014, at 6:01 PM, Peter Lawrey notifications@github.com wrote:

Do you think it makes sense to have a replaceReturnsNull(true) flag?

On 5 March 2014 10:00, Peter Lawrey peter.lawrey@gmail.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the
replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either.
acquireUsing doesn't create any objects when used correctly, it is more
like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I
have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL
will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious
non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying
for (
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14>
.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36667028
.


Reply to this email directly or view it on GitHub.

@RobAustin
Copy link
Contributor

These methods although similar, are not identical, I will refactor out the commonalities though

Sent from my iPad

On 4 Mar 2014, at 23:00, Peter Lawrey notifications@github.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the
replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either.
acquireUsing doesn't create any objects when used correctly, it is more
like assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com wrote:

While not universally in computing, it think it is clear enough. I have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious non-NULL
will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious
non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying for
(
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14>
.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36667028
.


Reply to this email directly or view it on GitHub.

@peter-lawrey
Copy link
Owner

Refactoring is a nice to have for the alpha release, we should go back and
refactor for the beta release.

On 5 March 2014 10:10, Rob Austin notifications@github.com wrote:

These methods although similar, are not identical, I will refactor out the
commonalities though

Sent from my iPad

On 4 Mar 2014, at 23:00, Peter Lawrey notifications@github.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the
replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either.
acquireUsing doesn't create any objects when used correctly, it is
more
like
assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com
wrote:

While not universally in computing, it think it is clear enough. I
have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com
wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious
non-NULL
will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious
non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying
for
(
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14>
.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028>

.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36690859
.

@RobAustin
Copy link
Contributor

Ok - I'll focus on more important tasks for the moment.

Sent from my iPad

On 4 Mar 2014, at 23:11, Peter Lawrey notifications@github.com wrote:

Refactoring is a nice to have for the alpha release, we should go back and
refactor for the beta release.

On 5 March 2014 10:10, Rob Austin notifications@github.com wrote:

These methods although similar, are not identical, I will refactor out the
commonalities though

Sent from my iPad

On 4 Mar 2014, at 23:00, Peter Lawrey notifications@github.com wrote:

What you could do is treat remove(K, V) as replace(K,V, null) where the
replaced value of null implies a delete.

On 5 March 2014 07:07, Peter Lawrey peter.lawrey@gmail.com wrote:

The problem is that it doesn't strictly create anything either.
acquireUsing doesn't create any objects when used correctly, it is
more
like
assigned-to-existing-record-or-allocate-a-new-record-and-assign-it.

On 5 March 2014 06:59, Rob Austin notifications@github.com wrote:

I was struggling to understand what acquireUsing() does, for me
getOrCreate() is much clearer.

Rob

On 4 Mar 2014, at 19:55, Peter Lawrey notifications@github.com
wrote:

While not universally in computing, it think it is clear enough. I
have
seen "acquire" used quite a few time.

http://www.oxforddictionaries.com/definition/english/acquire

"acquire [verb] buy or obtain (an asset or object) for oneself."

For me,

newXxxx => create a new thing always
getXxxx => get if present.
acquireXxxx => get if present or create if not.

On 5 March 2014 04:59, Ben Cotton notifications@github.com
wrote:

Do you think it might be a little clearer if the

V acquireUsing(Object key, V value);

signature was changed to

V getOrCreate(Object key, V value); //makes it more obvious
non-NULL
will be returned.

or possibly

V getNonNull(Object key, V value); //makes it totally obvious
non-NULL will be returned.

?

Keeping the current signature is fine, of course, I'm just saying
for
(
simple minded ) me the last one makes it easier to remember which
signature
can't return NULL. ;-)

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14>
.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHub<
https://github.com/OpenHFT/HugeCollections/issues/14#issuecomment-36667028>

.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36690859
.


Reply to this email directly or view it on GitHub.

@leventov
Copy link
Contributor

leventov commented Mar 5, 2014

Don't forget about IDE autocomplete. If I forget acquireUsing method name (that's easy), I want to type "map.get", then Ctrl+Enter to see all kinds of get available. Simple get creates an object as well in sense we mean when consider getOrCreate name for acquireUsing, thus I'd suggest getOrReuse.

@RobAustin
Copy link
Contributor

I agree

On 5 Mar 2014, at 04:30, Roman Leventov notifications@github.com wrote:

Don't forget about IDE autocomplete. If I forget acquireUsing method name (that's easy), I want to type "map.get", then Ctrl+Enter to see all kinds of get available. Simple get creates an object as well in sense we mean when consider getOrCreate name for acquireUsing, thus I'd suggest getOrReuse.


Reply to this email directly or view it on GitHub.

@peter-lawrey
Copy link
Owner

getUsing will always reuse, not "get OR reuse". acquireUsing will also
always reuse. The difference is that acquire will never return null.

On 5 March 2014 17:59, Rob Austin notifications@github.com wrote:

I agree

On 5 Mar 2014, at 04:30, Roman Leventov notifications@github.com wrote:

Don't forget about IDE autocomplete. If I forget acquireUsing method
name (that's easy), I want to type "map.get", then Ctrl+Enter to see all
kinds of get available. Simple get creates an object as well in sense we
mean when consider getOrCreate name for acquireUsing, thus I'd suggest
getOrReuse.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36715393
.

@leventov
Copy link
Contributor

leventov commented Mar 5, 2014

getUsingOrCreate

@Cotton-Ben
Copy link
Author

We also initially felt awkward with the choice "acquireUsing" ... but
that awkwardness truly wore off (and in very little time). We made the
gentle effort= "let us try to adapt to its name" rather than "let it
adapt to our name". For us it worked. "acquire' is a richer, more
regal verb. As Peter points out, it overloads in-place full
"getOrCreate" semantics (without the need of a literal in-order binary
conjunctive). It took all of a 2 minutes of our practicing "you can
'get' a NULL" but you can't "acquire" a NULL. By the third minute, we
were in love with "acquireUsing" ... so much so that we closed #13.

On 3/5/2014 6:21 AM, Peter Lawrey wrote:

getUsing will always reuse, not "get OR reuse". acquireUsing will also
always reuse. The difference is that acquire will never return null.

On 5 March 2014 17:59, Rob Austin notifications@github.com wrote:

I agree

On 5 Mar 2014, at 04:30, Roman Leventov notifications@github.com
wrote:

Don't forget about IDE autocomplete. If I forget acquireUsing method
name (that's easy), I want to type "map.get", then Ctrl+Enter to see all
kinds of get available. Simple get creates an object as well in sense we
mean when consider getOrCreate name for acquireUsing, thus I'd suggest
getOrReuse.

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on
GitHubhttps://github.com//issues/14#issuecomment-36715393
.


Reply to this email directly or view it on GitHub
#14 (comment).

@leventov
Copy link
Contributor

leventov commented Mar 5, 2014

OK, you convinced me.

@peter-lawrey
Copy link
Owner

get() creates an object.

acquireUsing(key, non-null) and getUsing(key, non-null) never create an
object or use more memory.

I think it would be confusing to put "Create" on the method which doesn't
create, while the method called just get() does create.

On 5 March 2014 22:26, Roman Leventov notifications@github.com wrote:

getUsingOrCreate

Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-36733094
.

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

4 participants