collection naming – singular or plural [closed]

This is related to this question but not quite the same. BTW, I’m not a native English speaker.

I keep having a hard time choosing a proper name for collections – Lets say that we have a collection of item s and that each item has a name. How will we call the collection of names such that the collection’s name will be the most understandable under standard naming conventions?

var itemNames = GetItemNames(); // Might be interpreted as a single item with many names
var itemsNames = GetItemsNames(); // No ambiguity but doesn't look like proper English
var itemsName = GetItemsName(); // Also sounds strange, and doesn't seem to fit in e.g. a loop:
foreach( itemName in itemsName){...}

As native English speakers, how would you name your collections, and how would you expect them to be named?

0

What about GetNamesOfItems?

Otherwise, GetItemNames can be a good alternative, if the documentation is clear about what is being returned. This also depends on the items itself:

  • GetPersonNames is not clear, since a person can have multiple names,

  • GetProductNames is more explicit in a context where a product can have one and one only name.

GetItemsNames looks indeed quite strange.

GetItemsName is simply incorrect: we expect as a result a common name shared by multiple items, not a sequence of names.


As an example, take a method which returns the prices of products in a category:

public Money[] NameHere(CategoryId categoryId) { ... }
  1. GetProductPrices could have been interpreted in two ways: either it returns the prices of products, or several prices of a product, one price per currency. In practice, given that the parameter of the method is a category, and not a single product, it is obvious that the first alternative is true.

  2. GetPricesOfProducts appears the most clear alternative. There are zero or more products in a category, and for each, we return its price. The only issue is the case when there are actually several prices per product, one price per currency.

  3. GetProductsPrices looks strange, but is still clear.

  4. GetProductsPrice looks totally wrong: we expect such method to return Money, not Money[].

Also note that in the example above, it may be even better to slightly change the signature itself:

public Tuple(ProductId, Money)[] GetPricesOfProducts(CategoryId categoryId) { ... }

appears easier to understand and removes the ambiguity described in the second point.

2

In English, this would be “get the items’ names”. If you want to think of an “item name” as an independent thing, then “get the item names” would also be acceptable. Here I would have used GetItemNames() without a second thought, so I would recommend either that or GetNames(items) or items.GetNames().

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật