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.
相关文章