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

Reconsider function naming #4

Open
strogonoff opened this issue Sep 28, 2023 · 1 comment
Open

Reconsider function naming #4

strogonoff opened this issue Sep 28, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@strogonoff
Copy link

strogonoff commented Sep 28, 2023

There are functions named like MMELToText or MMELtokenize which is somewhat unconventional in JS/TS ecosystem.

  • One convention is that identifier name may not start with a capital letter, unless it’s a class (or in case of TS a type). Which means an initialism (e.g., MMEL) should be lowercased if you want to start function name with it. There are many examples of initialisms being lowercased in properties (e.g., bgColor or ariaSort). Not so many in functions, because functions tend to start with a verb.

  • Another convention, slightly more loose, is that function names that can easily start with a verb should. See many examples in Web APIs: you will see getAttribute, setHTML but not attributeGet or HTMLset. Which would suggest, e.g., tokenizeMMEL instead of MMELtokenize.

    There are some exceptions to this convention, like conversion functions, in which case convertXToY is a bit long so you will just see xToY or even xtoy. However, they still follow the first rule, in that if initialism goes first it is lowercased. For example, you will see atob and btoa functions (where “a” is for “ASCII” and “b” is for “binary”) on the Web, and urlToHttpOptions and fileURLToPath in Node.

  • Additionally, there is a bit of internal inconsistency between MMELToText and MMELtokenize (something should be changed, either MMELtotext or MMELTokenize), but I think it should better be addressed by following the above conventions in the first place.

@ribose-jeffreylau
Copy link
Contributor

Agreed. Will change API in next minor version update.

@ribose-jeffreylau ribose-jeffreylau self-assigned this Sep 28, 2023
@ribose-jeffreylau ribose-jeffreylau added the enhancement New feature or request label Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants