简体   繁体   English

复合对象的复数命名约定

[英]Plural naming convention for composite objects

The question is about the correct way to name variable or identifiers that groups collections of two or more "things".问题是关于命名变量或标识符的正确方法,这些变量或标识符将两个或多个“事物”分组 collections。 Let me explain a little further with example and question...让我用例子和问题进一步解释......

  • If you something that holds an id you may name it with the identifier "id"如果你拥有一个 id 的东西,你可以用标识符“id”命名它
  • If you got somethign that holds an appoinment you may name it "appointment" as identifier如果你有一些持有约会的东西,你可以将它命名为“约会”作为标识符
  • If you got multiples ids (for example, an array) you may name it "ids"如果您有多个 ID(例如,一个数组),您可以将其命名为“ids”
  • If you got multiples appointments under an array you may name it "appointments"如果您在数组下有多个约会,您可以将其命名为“约会”
  • If you got multiples appointments' ids, how may i name it?如果您有多个约会的 ID,我该如何命名?
    • appointmentIds?约会ID?
    • appointmentsIds?约会ID?

I'm not an english native speaker.我不是以英语为母语的人。

In your example you'd name it "appointmentIds", as it's multiple Ids for your appointment type ie Ids for many different appointments.在您的示例中,您将其命名为“appointmentIds”,因为它是您的约会类型的多个 ID,即许多不同约会的 ID。

"appointmentsIds" would imply the relationship between an appointment and its Ids ie the appointment (singular) has many different Ids, which from your example is not likely! “appointmentsIds”将暗示约会与其 ID 之间关系,即约会(单数)有许多不同的 ID,这在您的示例中是不可能的! I'd suggest reading up on nouns and the possesive (I appreciate English is not your first language, English is hard!)我建议阅读名词和所有格(我很感激英语不是你的母语,英语很难!)

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

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