- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
有些品牌名称实际上并不喜欢将其首字母大写,更改可以使其看起来完全不同,尤其是“iOS”。还有更多类似“mCore”、“macOS”等。当涉及到类名时,我应该将第一个字母大写还是保留原样?
例如“iOSCompatProxy
”与“IOSCompatProxy
”
最佳答案
对于这种类型的类名,没有普遍遵循的约定。即使像“XML”这样的常规大写缩写也会导致不一致;查看the official JDK class list ,我看到名为 XMLSomething
的类与 XmlSomething
一样多。
Google 在 Google Java Style Guide 中处理此主题,他们给出了将文本转换为类名的方案:
Sometimes there is more than one reasonable way to convert an English phrase into camel case, such as when acronyms or unusual constructs like "IPv6" or "iOS" are present. To improve predictability, Google Style specifies the following (nearly) deterministic scheme.
Beginning with the prose form of the name:
Convert the phrase to plain ASCII and remove any apostrophes. For example, "Müller's algorithm" might become "Muellers algorithm".
Divide this result into words, splitting on spaces and any remaining punctuation (typically hyphens).
- Recommended: if any word already has a conventional camel-case appearance in common usage, split this into its constituent parts (e.g., "AdWords" becomes "ad words"). Note that a word such as "iOS" is not really in camel case per se; it defies any convention, so this recommendation does not apply.
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
Finally, join all the words into a single identifier.
他们的方案产生 IosCompatProxy
作为类名,iosCompatProxy
作为变量名。他们故意无视原始大小写,转而采用更基于规则的驼峰式大小写形式。
也许这不是最漂亮的形式,但如果您正在四处寻找可以遵循的规则,而您工作的地方没有这样的规则,Google 的风格指南是尽可能好的规则,因为它特别提到了“iOS”。我倾向于高度评价他们的约定,因为他们维护着大量使用它们的 Java(截至 2018 年有 3 亿行 [1])。
关于java - 当我们在类名中使用 "i"作为单词时,我们应该将 "iOS"大写吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54473245/
请帮助我..我被困在这里.. 我真正想要的是检查密码是否重复单个字符或数字。 重复要求 aaaa = 假, abbb = 假 abag = 假 a33f = 假 abcd1234 = 真 一个字符在密
在 Ant 中,我有一个名为 ' some_property 的属性。 ',假设它的值为“hello”。 我正在尝试 替换文本文件中的占位符 将此属性的值(“ hello ”)作为 大写 . 所以,我
var temp=["dy34","fd","FD","av","AV","12esu",1,"DY34",1011,123,101]; 当我对数组进行排序时,我得到的结果是: result = [1
var font_name = $(".font").val(); 我的 JavaScript 代码中有这个。在我的 html 中,我有一个带有 .font 类的输入表单。 我想将 .font 中每个
有人可以解释一下我如何实现文本转换:大写; sIFR 3 的功能? 在文档上,它解释了如何使用它,但我真的不知道如何实现它。有人可以举个例子吗? Specifes text transformatio
这个问题已经有答案了: String contains - ignore case [duplicate] (5 个回答) 已关闭 3 年前。 我需要定义我的查询是 DDL 还是 DML。为此,我需要
所以我一直在用 Java 编写一小段代码,它从用户那里获取输入,计算大写字母、小写字母和其他部分(例如空格、数字,甚至括号),然后返回每个部分的数量用户。 我遇到的问题是,如果我输入“Hello Th
在土耳其语中,有两个 i 无点:ı,I 虚线:i,© 问题:每次我将 i 大写时,我得到的是 I。 当我将 i 大写时,我想得到一个 İ(仅限土耳其语),以及一个I 当我将 ı 大写时。 我有一个函数
使用点符号向数组添加属性是否会将其更改为对象? var arr = []; arr.something = "test"; 是数组吗? 我不这么认为,但 underscore.js 说是 consol
我希望 TextBlock、Label、MenuItem.Header 中的所有文本都以大写显示。字符串取自 ResourceDictionary 例如: 等等。 (也适用于 Label 和其他控
我正在尝试计算包含用户定义范围内所有大写字符的单元格实例的数量,我已经有一些代码可以循环并正确突出显示这些大写单元格,但我正在努力应用该逻辑到VBA 的 Countif 函数。这是我得到的代码,但它给
我正在使用 dplyr 进行数据清理。 我想做的一件事是将某些列中的值大写。 data$surname john Mary John mary ...
为什么低于一个不起作用?我需要转换 IsValue转换成大写值,然后需要用 NO 检查它值(value)。我该怎么做? {{item.IsValue}} 最佳答案 确保 uppercase在比较
我需要将相同的变量转换为大写|小写|大写。 /** * @package ${1 default="Hello"} * @subpackage ${com}_${1 capitalize
显然,拉丁字母表也是如此。但我是在概念上提出这个问题,跨越语言和 Unicode 规范。 实际上,这是为了比较两个字符串。如果你已经知道它们的字节数不同——在所有语言中——你能认为这足以保证它们不是同
今天我更新了我的 Octopress 博客,当我运行时: rake new_post["This is a test of title"] 它在 source/_post/2013-02-18-thi
除了大写部分之外,我的程序正在运行:以下是将英语单词 englishWord 翻译为 Pig 拉丁语单词 pigLatinWord 的方法:A。如果英语单词中没有元音,那么pigLatinWord就是
通过使用一个输入文本框,输入类型只允许字母。输入的值为'a',它应该在文本框外显示为'A'? 如果我们在输入文本中输入小写字母“a”,那么它会希望在框外显示大写字母“A”...以下是我的html代码:
我正在开发一个特殊的脚本来修复文本区域内的字母。我在堆叠时发现了一个问题。在 Stackoverflow 上,我找不到解决方案,需要帮助。 我的脚本有一个系统,用于识别每个以大写首字母开头的单词,以及
我在 bash 中有以下行: echo "Manufacturer: $(echo ${family:-$name}|cut -d' ' -f1)" 我想使用 ${var^} 语法将回显字符串大写,但
我是一名优秀的程序员,十分优秀!