I'm working with a team of non-native English speakers and I'm struggling to come up with a rule that explains why a method should be called getFilePath and not getPathFile.

Examples of this bad naming come up on a daily basis and except for just pointing out the better name, I cannot figure out a good way to explain why words should be in a specific order, except for "It how it's written in English". Especially for variable names like this one since none of its components are adjectives.

I realize this is very basic and probably second nature to everyone here, but I think that's why I'm struggling to figure out how to explain it to people who don't understand it.

How would you explain it?

  • 2
    see How do I explain ${something} to ${someone}?
    – gnat
    Aug 13, 2019 at 9:19
  • 4
    Word order is crucial in English. There are very few so-called "postpositive adjectives", and they appear almost entirely in archaic language. If the code is to be written in English, then the simple answer is that the code must comply with principles of English - you can say "FilePath" or "PathOfFile", but "PathFile" is not correct, unless it obviously complies with a naming convention as would be perceived and understood by English-speaking developers in a context (e.g. GetDateBirth, GetDateMarried, GetDateDeath, where it is understood that all methods relate to getting the dates of things).
    – Steve
    Aug 13, 2019 at 14:49
  • 3
    English contains possessive nouns, whereas many other languages do not. So getFilePath is just a contraction of "get file's path". In other languages, it would be expressed in the form "get path of file". That's why expressing it as getPathFile makes sense to folk who do not have English as their first language. But in English it reads as "get path's file" which is the wrong way around.
    – David Arno
    Aug 14, 2019 at 9:59
  • @DavidArno awesome explanation! Aug 14, 2019 at 10:08
  • @DavidArno if you elaborated on your comment in an answer, I'd love to accept it. Aug 18, 2019 at 11:31

3 Answers 3


Solution 1:

Tell your team that the verb is related to the last word of the identified, and that the other words in-between give additional details, the importance of which is decreasing from right to left. So, if they want to get a path it's getPath(). If they want to say it's the path of the file, they add the detail in-between getFilePath(). if this file path is long, they could add this extra detail: getLongFilePath().

Conversely, you can propose a self-assessment test: would a simplified identifier with only the first and last word still be accurate ?

    getPath() -> getPath() :  ok 
    getFilePath() -> getPath() : ok
    getPathFile() -> getFile() : not ok, because the string of the path is not a file descriptior.  

Solution 2:

Organise some workshop on writing better identifiers. The best would be to do this with a language trainer who could focus on how to build nice simple nominal group in English.

  • 1
    – Ewan
    Aug 13, 2019 at 16:15

I cannot figure out a good way to explain why words should be in a specific order, except for "It how it's written in English"

That's because it is the only reason for writing it this way.

There is a naive view that there is a consensus that all programming should be done in american English. But this isn't really the case, let the developers choose names that they understand. Add intellisense comments for alternate languages

  • Well... yes... but... IF you go with English, you might as well do it right according to English rules. And if you are in a non-English environment where there is the slightest chance that some foreigner will have to do maintenance or review on the code, there is a lot to say for doing everything in English from the start. Aug 13, 2019 at 10:42
  • ...which does bring new challenges to some as the ones pointed out in the question. Up to the point that it is hard to understand what they even mean. With some comments or issue descriptions encountered I have to translate back to my native language, in the most literal way possible, in order to understand what the writer meant to say. :-) Aug 13, 2019 at 10:43
  • @MartinMaat tell that the microsoft with their "color" and "deserialization" etc!!
    – Ewan
    Aug 13, 2019 at 11:06
  • Yeah the thing is that it's an existing codebase written and maintained in American English, and we want to keep it consistent. Aug 13, 2019 at 11:34
  • @Ewan i.pinimg.com/736x/9d/bf/dd/… Aug 13, 2019 at 12:25

"File Path" is a noun phrase. You want to find a way to explain the syntax of noun phrases in english, in particular where the head noun appears (at the end in this and similar phrases), and that the the value returned should be an instance of the thing named by the head noun.

Your function presumably returns a path, in particular the path of a file. If you swap the words you would imply that it would return a file, of the sort that relates to a path.

  • 3
    – Ewan
    Aug 13, 2019 at 16:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.