Search code examples
coding-stylenaming-conventionsnamingcode-conversion

Does the method name need to be grammatical?


I have a question that may seem silly, my english is not very good, I often don't know how to name variables or methods.

For example, There is a method, its function is to open a modal for creating users, I will name it openCreateUserModal, Its corresponding English sentence is "open create user modal", I think this is not grammatical in English because there are two verbs. Would it be better to name it openCreatingUserModal?Or the method name does not need to follow English grammar?

I want to get a rule for naming complex methods


Solution

  • openCreateUserModal is perfectly fine. It clearly conveys what the function does. Following the rules of english grammar is not important in this context as long as the function name clearly indicates what the function does.

    Since you haven't mentioned any particular language, below is a source c# naming conventions. The principles are the same for any programming language.

    https://csharp-book.softuni.org/Content/Chapter-10-methods/method-naming/method-naming.html