美文网首页
[ITA Training] Learn about funct

[ITA Training] Learn about funct

作者: EmilioWeng | 来源:发表于2019-07-09 21:59 被阅读0次
    • 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 funct

          本文链接:https://www.haomeiwen.com/subject/fwxqkctx.html