简体   繁体   English

Java:复数首字母缩略词的命名约定

[英]Java: Naming convention for plural acronyms

I know there had already been similar discussions on such naming conventions. 我知道有关此类命名约定的类似讨论。 However, I'm having problem with plural acronyms. 但是,我遇到了复数首字母缩略词的问题。

public List<Disc> findAllDvds(DiscHolder holder) {}
public List<Disc> findAllDvd(DiscHolder holder) {}

Assuming that I have decided to use CamelCase for acronyms, which of the two is generally more acceptable? 假设我已经决定使用CamelCase作为首字母缩略词,那两者中的哪一个通常更容易被接受?

Edit 编辑

I am aware this will invite opinion-based answers, but sometimes when you are in doubt, you just need people to give advises and feedbacks. 我知道这将引发基于意见的答案,但有时当你有疑问时,你只需要人们提供建议和反馈。

To add on, the confusing part here is that findAllDvds can imply a new acronym DVDS , and it can be considered confusing. 另外,这里令人困惑的部分是findAllDvds可能意味着一个新的首字母缩略词DVDS ,它可以被认为是令人困惑的。

The first ( findAllDvds ). 第一个( findAllDvds )。 The second ( findAllDvd ) is simply incorrect, "all" implies more than one, but "Dvd" is singular in English. 第二个( findAllDvd )是不正确的,“all”意味着不止一个,但“Dvd”在英语中是单数的。

Re your edit: 重新编辑:

the confusing part here is that findAllDvds can imply a new acronym DVDS , and it can be considered confusing 这里令人困惑的部分是findAllDvds可能意味着一个新的缩写DVDS ,它可以被认为是混乱

Since the "all" implies multiple, the "s" on "Dvds" reads as a plural, not part of the acronym. 由于“all”意味着多个,“Dvds”上的“s”读作复数,而不是首字母缩略词的一部分。 If it really were DVDS, the name would be findAllDvdss or similar. 如果它真的是DVDS,名称将是findAllDvdss或类似。

It's said that in computer science, there are three hard problems: Cache invalidation, and naming things. 据说在计算机科学中,存在三个难题:缓存失效和命名事物。 (Off-by-one errors are just common, not hard.) (逐个错误只是常见的,并不难。)

This is a really opinion based question and could be closed. 这是一个基于意见的问题,可以关闭。

However, this should be the correct version: 但是,这应该是正确的版本:

public List<Disc> findAllDvds(DiscHolder holder) {}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM