[ITA Training] Learn about function naming by studying task

  • Common function naming styles:

    • Camel-Case: When multiple words make up a name, the first word is all lowercase, followed by the first letter uppercase.
    function printMultiplicationTable(startNum, endNum){}
    
    • Pascal: When multiple words make up a name, capitalize the first letter of each word.
    function PrintMultiplicationTable(startNum, endNum){}
    
  • Three principles of function naming

    • The first word is a verb
      Usually we choose a verb that describes what a function does, such as add, append, insert, create, get, delete, submit, etc.
      If you need to use a noun after the verb, pls use a common noun.
    • Function naming needs to be intuitive
      Function names should be clear, and it is better to include the meaning of input and output.
      There should be a connection between the function name and the function implementation.
    • Use professional nouns
      For example, capacity(容量) is usually called capacity, string length is usually called length instead of size.
      There are also many specialized words in the shipping industry, such as TEU, Vessel, sailing, port, etc.

I suggest you do a lot of work on function naming. You know what a function means when you see its name.

你可能感兴趣的:([ITA Training] Learn about function naming by studying task)