nuomiphp
正在加载…
请使用更现代的浏览器并启用 JavaScript 以获得最佳浏览体验。
加载论坛时出错,请强制刷新页面重试。
getUserId 还是 getUserID?
hahadaxigua834
Words in names that are initialisms or acronyms (e.g., URL and NATO) should have the same case. URL should appear as URL or url (as in urlPony, or URLPony), never as Url. This also applies to ID when it is short for “identifier”; write appID instead of appId.
https://google.github.io/styleguide/go/decisions#variable-names
SuperMild
hahadaxigua834
这个竟然是 Google 的 Go 语言风格,与 Go 自己的标准库不一样啊。比如 https://pkg.go.dev/database/sql#Result 用了 LastInsertId()以及这里 https://pkg.go.dev/os/user 用了 UnknownUserIdError 和 LookupId() 等
hst001
ID 和 URL 都是缩写,通常情况下要么全大写要么全小写
gowl
按微软的命名规则的话是 ID 和 Url 。
aoeui
gowl
别的语言不知道,按照 C# 的规则应该是 Id 和 Url
hahadaxigua834
SuperMild
他这个才刚出不久 https://github.com/google/styleguide/commit/9ae38d43e38a5b182092723d0f1295c3b80b1e06#diff-6da38f7fcd797f6019e0179e88edbdc80db2a6114d7468274376e5d786363565
HAWCat
自己统一了就行,各家都不一样的
securityCoding
golanglint-ci 规则强制 ID
duke807
get_usr_id()
get_xxx_url()
sifeizhai2020
Now lowercase everything (including acronyms), then uppercase only the first character of:
- ... each word, to yield upper camel case, or
- ... each word except the first, to yield lower camel case
https://google.github.io/styleguide/javaguide.html#s5.3-camel-case
Jooooooooo
ID 是 go 的风格, 写 java 的从来都是 Id
snw
我选 getUserId 和 getXxxUrl. 对于这种很常见的缩写单词,就当它普通单词对待,不然有时出现在函数名中间时维持同样的原则非常难受:getIDAsync, getURLList
lowsell
snw
确实有遇到这个场景,很是别扭
leonshaw
snw
两个缩写连着更难受
Knowazz
感觉后者比较顺眼
qeqv
这个问题也是困扰过我,现在我选择 Id Url
olaloong
我们的傻瓜 checkstyle 定死了不允许连续出现两个大写字母,so...
makelove
建议无脑算法,永远只大写第一个
vthe
get_user_id
ChefIsAwesome
按语法,缩写应该大写。但是现实中,很多不大写的情况。
以 url 举例,path 分大小写,协议和域名不分大小写。HTTPS://v2ex.COM 这地址你看着怪不怪。FBI 应该是全大写。FBI 的网址,只能是全小写的 fbi.gov 。
再例如,km/h 都是小写。
写驼峰,就别管缩写大写的问题。
WasteNya
gEtUsErId
下一页 »