nuomiphp
正在加载…
请使用更现代的浏览器并启用 JavaScript 以获得最佳浏览体验。
加载论坛时出错,请强制刷新页面重试。
getUserId 还是 getUserID?
lowsell
类似的 getXxxURL 还是 getXxxUrl
不确定应该用哪种,大家呢
nexo
ID URL
pdog18
似乎 ID 是合理的
iseki
少于三个字母我选 ID ,三个字母开始我宁可 Url
SuperMild
最标准的是 Id ,URL ,但实际操作没必要太计较。
pupboss
Id 是一个单词 identity 的缩写,url 是 uniform resource locator 缩写,4 楼说的就是标准答案了
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
感觉后者比较顺眼
下一页 »