V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
WildCat
V2EX  ›  程序员

变量命名问题,是 replies_count 还是 reply_count,是 topicList 还是 topicsList

  •  
  •   WildCat · 2015-02-12 19:08:15 +08:00 · 2211 次点击
    这是一个创建于 3373 天前的主题,其中的信息可能已经有所发展或是发生改变。
    在 GitHub 上搜了下这两种用法,发现数量都不小。
    6 条回复    2015-02-13 12:37:22 +08:00
    fortunezhang
        1
    fortunezhang  
       2015-02-12 19:46:36 +08:00   ❤️ 1
    banana trees ?
    bananas tree ?
    mthli
        2
    mthli  
       2015-02-12 19:50:42 +08:00 via Android   ❤️ 1
    replies_count(计算回复的次数,至少Dribbble API是这样的风格)。
    topicList(List已经有包含很多item的意思了,不需要单独为topic写复数)。
    raincious
        3
    raincious  
       2015-02-12 19:54:20 +08:00   ❤️ 1
    每当遇到这种无关紧要问题的时候,掏出一元钱硬币是最佳的解决方案了。

    不过貌似我从来没遇到过这种问题。
    topicList => topics
    replies_count => count_replies (count_likes、count_followers)

    我好机灵。
    mhycy
        4
    mhycy  
       2015-02-12 20:25:32 +08:00   ❤️ 1
    同一类型数据使用同样的前缀
    topicList/topics
    topicInfo

    下划线命名看应用,一般都是因为过长而使用驼峰法
    xhacker
        5
    xhacker  
       2015-02-13 07:09:25 +08:00
    reply_count, topicList
    pright
        6
    pright  
       2015-02-13 12:37:22 +08:00   ❤️ 1
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5514 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 08:06 · PVG 16:06 · LAX 01:06 · JFK 04:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.