question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plural vs. singular for certain core module names that aren't piece types in A3

See original GitHub issue

Question about our upcoming renaming plans. We said we would give all modules singular names. Some examples that make me think follow.

  • apos.areas: this is a module that is in charge of all areas, but that excuse isn’t good enough for a pieces module to be plural, so it’s not good enough here. So it becomes apos.area. Or I’m going crazy. Sure, fine.

There is no conflict with inserting an area in a template because that is {% area %} now. However it does mean that we might have to find another way of linting for projects with legacy 2.x apos.area calls in them. Because we can’t just replace apos.area with a helpful warning function if it is the name of a module. At least they will get an error (“not a function”).

  • apos.utils: this literally contains more than one utility. “Literally contains” is @localghost443 's suggested trigger for a plural. But, nodejs itself has a util module, which I’ve often found confusing because apostrophe contains a utils module. Do we rename our module to match?

  • apos.caches: in charge of all caches - yes, yes, not good enough - but the syntax is gonna be weird if we make it singular. apos.cache.get really, really sounds like it gets a value out of a cache! But it doesn’t. It gets you a cache, that you can get values from.

OK, big 👾 🧠 moment: I propose we fix this forever like so…

// Remember an oembed response from youtube
await apos.cache.set('oembed', 'https://youtube.com/v/something', { data... });
// Get it back later
await apos.cache.get('oembed', 'https://youtube.com/v/something');

We kill the idea of multiple cache objects as part of the API completely, and just always include a namespace name when getting and setting things. Having multiple caches, one per namespace, as part of the implementation under the hood depends on how the cache is implemented but an apostrophe developer should not care. They should have a simple, normal apostrophe module method they can call to get something. This also fixes our documentation about how to use the module, which is currently written in a weird way because of the “call get to get a cache object” issue.

Can I get a hell yeah?

  • I have been over the modules list in core and I think these are the only ones I’m unsure about.

cc @stuartromanek @abea @falkodev

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
boutellcommented, Jul 23, 2020

I think given that everything else will be singular (no module other than utils comes close to Ben’s criteria for a plural), and that Node.js uses the singular for its core util module which is in a very similar spirit and used by most node developers, we should go with all singular. Looks like we have a consensus here!

2reactions
falkodevcommented, Jul 23, 2020
  • apos.area ✅
  • apos.cache ✅
  • apos.util:
    • the argument to have it plural can be applied to the other 2 categories here
    • you get only one “util” at a time anyway => apos.util.generateId()
    • I like the fact Node uses it as a singular too

Sorry to be a pain 😬  I won’t fight if everyone else prefers the plural form of util 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Should I use Singular or Plural name convention for REST ...
As a user of a RESTful service I'd expect the list resource to have the same name no matter whether I access the...
Read more >
Singular and plural nouns | EF | United States
There are some irregular noun plurals. The most common ones are listed below. Examples. Singular, Plural. woman, women. man, men.
Read more >
d%26d ruins battle map
The names aren't based on ruins in real life, as their names are usually simply the name these structures were given before they...
Read more >
object oriented - Should package names be singular or plural?
Use the plural for packages with homogeneous contents and the singular for packages with heterogeneous contents. A class is similar to a ...
Read more >
Collective Nouns: Definition, Examples, & Exercises | Albert.io
Collective nouns can be singular or plural, but plural nouns are always ... in particular, often use the plural form of the team...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found