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“是"
基础教程推荐
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- JPA惰性列表上的流 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
