3 ms·
As a native English speaker (and former English teacher), hope this helps: > getInstances(); // ok, returns an array of instances Correct. > getInstanceId();
by crazygringo 6y ago
As a native English speaker (and former English teacher), hope this helps:
> getInstances(); // ok, returns an array of instances
Correct.
> getInstanceId(); // ok, returns an id
Correct.
> getInstancesId(); // ??, returns an array of id
Unusual, but would return a single ID referring to a collection of instances.
> get InstancesIds(); // ?? returns an array of id
Correct.
Though more common would be getInstanceIds() since you don't need to pluralize twice. E.g. we don't say "blues shoes", we say "blue shoes", so these aren't "instances ID's" but "instance ID's".
However, in naming functions or variables you'll sometimes see plurals repeated for clarity. E.g. getInstanceIds() is ambiguous because it could refer to the ID's of multiple instances, or multiple ID's of the same instance. While getInstancesIds() makes it clearer that it's the ID's of multiple instances, even though it's not actually grammatically correct.
> getIdsOfInstances(); // ?? returns an array of id
Same as getInstanceIds(). Both are correct, though getInstanceIds() would probably be more common -- most people wouldn't put in the extra word "of" simply because it's an extra word, but sometimes it might be clearer for consistency with other function names.
> getAllInstancesId(); // ?? returns an array of id
It would mean the ID for the collection of all instances, though that would seem very unusual. Perhaps if there were a global account ID for a service or API you used.
> getAllInstancesIds(); // ?? returns an array of id
Sams as getInstanceIds(), but "All" presumably means it doesn't include a parameter to filter -- so I'd assume this implied the existence of another function such as getCollectionInstanceIds() or similar that it was contrasted against.
> How do I conjugate that ? And what about the possessive `s`?
Obviously you can't or shouldn't use apostrophes in variable names, so people generally try to avoid the possessive s. That's why we generally change nouns to noun adjectives -- instead of "computer's ID" (computer = noun) we use "computer ID" (computer = noun adjective).
- pcthrowaway 6y ago> Though more common would be getInstanceIds() since you don't need to pluralize twice. E.g. we don't say "blues shoes", we say "blue shoes", so these aren't "instances ID's" but "instance ID's". Completely agree with all your points (as a native English speaker who also minored in English) However, for the sake of clarity (since we're trying to disambiguate between places the 's' could indicated possession vs. plurality) "instance IDs" should not have an apostrophe. The only time an apostrophe goes in a non-possessive plural is in a contraction. E.g. "the '90s" Then we also have fun words that probably should never be used which get an apostrophe on both ends (contraction at beginning + possessive plural) e.g. " ... the '60s' countercultural attitudes ..." But for clarity it might be better to go with "... the countercultural attitudes of the '60s ..."
- crazygringo 6y agoThat's a hotly debated issue that different style guides give different answers to. Some style guides insist plural all-capital abbreviations should never have an apostrophe ("IDs"), other insist they should ("ID's"). Your personal usage is absolutely valid, but it should be recognized as opinion and not fact. "ID's" is equally valid in modern usage. Edit: You can read an extensive discussion of it here: https://en.wikipedia.org/wiki/Acronym#Representing_plurals_and_possessives https://en.wikipedia.org/wiki/Acronym#Representing_plurals_a...
- pcthrowaway 6y agoInteresting. I've seen the apostrophe for acronyms which involve periods: e.g. "C.D.'s" (NYT has an article about this being their preferred style) I've seen it for one-letter words where you don't want to switch case: e.g. "dot your i's and cross your t's" But I haven't seen it in upper-cased abbreviations followed by a lower case plural 's'. Or if I have, I've assumed it's wrong. Would love it if you can refer me to a modern style guide which doesn't recommend dropping the `'` in this usage, as my own background has drilled into me that "IDs" is preferred for clarity.
- crazygringo 6y agoI just added a link to a Wikipedia discussion in my comment above, which should answer your question. It gives an example: > ...whereas The New York Times Manual of Style and Usage requires an apostrophe when pluralizing all abbreviations regardless of periods (preferring "PC's, TV's and VCR's").
- samatman 6y agoI would make a case that in our field, one which has an abundance of initialisms and non-period-separated acronyms, we shouldn't shadow the possessive. Consider "this script retrieves JSONs from all API URLs and validates them against their respective schemas" and "this function extracts the URL's fragment, if any, and checks it against a set of page targets". If you use an apostrophetic plural, does the latter receive one URL, or a collection of them? URL was carefully chosen, since you can't make a consistent ruling about initialism vs. acronym, I've worked with people who pronounce it "you are ell" and people who say "earl", and sometimes both! Absolutely no one is going to start spelling it U.R.L., either. Especially given the abundance of non-native speakers, let's not add a peculiar and ambiguous edge case to one of the more frustrating rules of English grammar.
- repsilat 6y agoOne thing that getInstancesIds() might mean is "get the (multiple) ids for each of multiple instances". I don't know why an instance would have more than one id, probably more plausible with different nouns, but a similarly named function might return an array of arrays, or a flattened equivalent, possibly uniqued. Probably a bad idea though. I have been guilty (though pleasurably, pridefully guilty) of abusing plurals -- day, days, dayses etc. If you can let the types do the talking that's obviously better, and more descriptive (and less eccentric) names can help a lot with communication and clarity, but there is also sometimes a place for brevity, and for levity.