Cbdy
V2EX  ›  问与答

各位大佬是怎么处理变量命名的复数名词问题的?

  •  
  •   Cbdy · Mar 11, 2020 · 1816 views
    This topic created in 2281 days ago, the information mentioned may be changed or developed.

    有的框架、约定会把数据库的表名,代码逻辑中的 List、Array 等对象用复数名词来命名

    比如

    const babies: Baby[] = []
    

    但有时会遇到拼错或拼不出查字典的情况,如

    user -> users
    potato -> potatoes
    wolf -> wolves
    baby -> babies
    mouse -> mice
    child -> children
    fish -> fish

    各位大佬是怎么处理变量命名的复数名词问题的?有什么最佳实践吗?单数名词+List 后缀?

    3 replies    2020-03-11 15:50:36 +08:00
    ipwx
        1
    ipwx  
       Mar 11, 2020
    userList 它不香?
    optional
        2
    optional  
       Mar 11, 2020
    babies babyList babyArr babyVec
    arthas2234
        3
    arthas2234  
       Mar 11, 2020
    楼上+1,之前也用过单词的复数形式,后面公司考虑到部分同事的工地英语,现在用的是:单数+List/Map/Set/Array
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5486 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 67ms · UTC 08:54 · PVG 16:54 · LAX 01:54 · JFK 04:54
    ♥ Do have faith in what you're doing.