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“是"


- Eclipse 插件更新错误日志在哪里? 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01