Java boolean getters quot;isquot; vs quot;arequot;(Java 布尔吸气剂“是vs“是)
问题描述
我知道 Java 中布尔 getter 的约定是包含前缀is".
I know that the convention in Java for boolean getters is include the prefix "is".
isEnabled
isStoreOpen
但是如果主语是复数呢?也就是说,如果我不想知道一家商店是否营业,而是想知道所有商店是否都营业,该怎么办?
But what if the subject is plural? That is, what if instead of wanting to know if a store is open, I wanted to know if all the stores are open?
isStoresOpen()
在英文中没有意义.
我很想写像这样的吸气剂:
I'm tempted to write getters like:
areStoresOpen
areDogsCute
areCatsFuzzy
我认为这是有道理的,但其他人告诉我,我应该接受它并放弃主语动词协议并使用 isStoresOpen
、isDogsCute
, isCatsFuzzy
.
And I think that would make sense, but I've been told by others that I should just suck it up and abandon subject verb agreement and use isStoresOpen
, isDogsCute
, isCatsFuzzy
.
无论如何,对于在复数主题上操作的布尔 getter,我应该怎么做?
Anyway, what should I do for boolean getters which operate on a plural subject?
推荐答案
我不记得这是出自哪本书,但本质是代码的阅读次数比编写次数要多得多.为了可读性而写.
I can't remember which book this was from, but the essence is that code will be read many more times than it's written. Write for readability.
这篇关于Java 布尔吸气剂“是"vs“是"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Java 布尔吸气剂“是"vs“是"
基础教程推荐
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 降序排序:Java Map 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01