英文:
What is the Java naming convention for list of objects which have plural forms ending with "ies" or non-standard "s" plural forms?
问题
我找不到涵盖不遵循标准“s”复数形式的单词用法的Java命名约定。
//给定一列生物,getter方法应该是什么?
private List<Biology> biologies;
public Biology getBiology();
public List<Biology> getBiologies();
当复数形式差异很大时,约定是什么?
//给定一列章鱼,getter方法应该是什么?
private List<Octopus> octopi;
public Octopus getOctopus();
public List<Octopus> getOctopi();
英文:
I am unable to find any naming conventions for Java that covers the usage of words that does not follow the standard "s" plural form.
//Given a list of biologies, what should the getter method be?
private List<Biology> biologies;
public Biology getBiology();
public List<Biology> getBiologies();
What is the convention when the plural form is much different?
//Given a list of octopi, what should the getter method be?
private List<Octopus> octopi;
public Octopus getOctopus();
public List<Octopus> getOctopi();
答案1
得分: 5
这只是一个意见的边缘,但我称之为“最佳实践”并说:
使用复数形式并且拼写正确。
就像你应该拼写所有的变量/字段正确一样(如果清楚的话,长术语的缩写是可以接受的,例如 min
,max
等)。
不具有权威性,但Intellij会自动生成拼写正确的复数形式,例如:
List<Company> x; // 重命名为“x”后会自动建议“companies”
英文:
This is on the edge of opinion, but I'm calling "best practice" and saying:
Use plurals and spell them correctly.
Just as you should spell all variables/fields correctly (abbrevations of long terms being acceptable if clear, eg min
, max
etc).
Not authorative, but Intellij auto-generates correctly spelled plurals, eg:
List<Company> x; // "companies" will be auto-suggested if you rename "x"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论