4

In a few projects I've seen names like "foundedFile" and "bindedDatasource". What would be the industry consensus be: leave it as it is, use correct English "foundFile" / "boundDatasource", try to avoid irregular verbs in naming where they cause misunderstanding?

New contributor
Alexey Krasheninnikov is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
3
  • Whatever you choose, make sure everybody uses the same terminology, and in that case it might well be the correct one 😊 Commented 16 hours ago
  • Develop your own ubiquitous typo-set? Commented 15 hours ago
  • During PR review, prefer the correct word. // I usually will name a local variable referrer, despite the protocol having enshrined a typo in the headers that the client sends. Commented 8 hours ago

4 Answers 4

8

There are two hard things in computer science, naming is one of them.

In this case, it's not so hard: Code should be easy to read, and the words used should not cause irritation, so using grammatically correct names is a good thing (although code will not follow the language grammar overall).

I would not go so far as to forbid irregular verbs for use by non-native speakers (how are they supposed to know whether a verb is irregular if their language proficiency is low?) but a healthy culture of improving code quality, including renaming and other actions which make the code more readable (preferably during review). If you use English words in code written by speakers who are prone to make mistakes at that level, the review should be done by someone who can spot and correct these mistakes.

9
  • 4
    We did that in a project long ago (of which I'm essentially the last maintainer), and I regret it almost every day. In that case, all the names in the standard libraries (Smalltalk) are verbose english, and so we have a mixture of removeSomething and irgendwasLoeschen method names. Commented 16 hours ago
  • 2
    I work with a lot of people whose secondary language is English. An approach I use in reviews is to simply comment, "can we rename this to people instead of persons?" Most times, that's good enough; the code author will know they aren't writing in their mother tongue, and this keeps the focus off of "bad grammar". It simply becomes a request to rename something. If it does spur questions from the author, then it becomes appropriate to talk about grammar, but there's no need to focus on it initially. Commented 15 hours ago
  • 1
    I have decades upon decades of experience speaking and writing English. And even after all this time I still need other people to catch my typos. Lets not make out that this is simply a problem for those who speak English as a second language. All code sucks. Use whatever time you have to make it better. Commented 13 hours ago
  • 1
    @BartvanIngenSchenau Emphatically use English names. English is the computer science and engineering lingua franca. If your English is deficient, learn better English. The level needed to find good names and read documentation is really not hard (compared to, say, German, Basque or Mandarin). Earlier or later, you will have an international team dealing with or even maintaining your code. Commented 8 hours ago
  • 1
    @BartvanIngenSchenau: Partial pushback from my end. Some of the nomenclature is technical plumbing (get, set, repository, service, disable, delete) and it is generally not helpful to translate this. However, there is an argument to be made for domain concepts when translation (and finite proficiency in English from devs who speak another language when communicating directly) can lead to inconsistencies or ambiguity. For example, worked on a government app and we have two distinct concepts of "citizen" which in English both translate to citizen. It was better to use the original names there. Commented 8 hours ago
1
  1. leave it as it is
  2. use correct English
  3. try to avoid irregular verbs

I think all these are potential solutions!

Obviously the starting point should be English as we know it.

Then you potentially adjust the vocabulary to avoid tricky results, including grammatical infelicities.

And finally if the "wrong" spelling or grammar is at least part of a rational scheme, then consider permitting it, though I think it is more customary in programming to break grammar rules than the conventional spellings (for example, Bind() and bool IsBind, or Find() and bool FindDone, rather than bool Binded and bool Finded).

Over the years I've also come to disfavour plurals for arrays/collections precisely because of the inconsistencies they lead to (currency/currencies, money/monies, person/people, before you even get to questions like schemas vs schemata). It's usually better to suffix with "set" or "list".

Merely ad-hoc and unintentional spelling mistakes by a writer unskilful with English, shouldn't be accepted outside the context of local variables.

0

With level of details from description quoted here for reference...

In a few projects I've seen names like "foundedFile" and "bindedDatasource". What would be the industry consensus be: leave it as it is, use correct English "foundFile" / "boundDatasource", try to avoid irregular verbs in naming where they cause misunderstanding?

... it is opinion based. To get objective answers the context needs to be detailed since the naming could be intentional either since it models some real life use cases or it is just a form of obfuscation from some obscure security concerns that when are not of interest anymore the way to go is speak the language the development team understands and that shouldn't require approval or be stated by guide lines, is just grammar we all have been taught before being taught programming.

New contributor
user485934 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
-2

I think you have the same problem with native speakers and plurals

Person person
Person[] persons //should be people, personArray? for correct english
Sheep sheep
Sheep[] sheep //should be sheeps? for coding standard collection naming

English has a bunch of crazy rules and often there isn't a good choice for variable names.

I've also seen spelling mistakes persist throughout large code bases.

I think there is a good argument for incorrect english where it provides consistency in variable names. eg say you have a bunch of paired functions

func click
bool clicked

func swipe
bool swiped

func error
bool errored //erred is correct english

func find
bool finded //found is correct english

func flavor   //flavour is correct
bool flavored //flavoured is correct

Given this, am I going to correct peoples grammar when they are programming in a foreign language? Seems like a richard move.

9
  • 6
    Ugh. "Finded". I'm not a native english speaker, but that hurts :-( Commented 16 hours ago
  • oops that had more meaning that i thought! thanks AI :/ Commented 16 hours ago
  • 2
    "//flavour is correct english" --- something I always forget is British versus American English. "Flavor" is correct in American English but incorrect in British English. A lot of people in my country (the USA) might not realize it, but British English tends to be taught around the world rather than American English - at least in India. I had a conversation years ago with one of my Indian coworkers, and he said they taught British English in primary school when he grew up. Just another language twist to account for. Commented 15 hours ago
  • 1
    @AlexeyKrasheninnikov - "founded" is a word, just not the past-tense of "find". Founded is used to describe when an organization was created. For example, "The United Nations is an international organization founded in 1945" (link). Clear as mud, right? Commented 13 hours ago
  • 1
    Yes, @GregBurghardt, I know, and it was implied in "misunderstanding" along with other meanings of "bound" and "bounded" Commented 13 hours ago

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.