开发者

Naming confusion? Is having objects named FlowerGroup and FlowerGroups confusing?

开发者 https://www.devze.com 2022-12-10 16:36 出处:网络
I\'m writing a program and I seem to be 开发者_StackOverflow社区creating alot of objects where one object will be the singular form and then the collection is the plural form. eg

I'm writing a program and I seem to be 开发者_StackOverflow社区creating alot of objects where one object will be the singular form and then the collection is the plural form. eg

SalesGroup SalesGroups

Is this confusing for other programmers to read my code?


should not be confusing, in fact I find it pretty informative and clear; unless you have multiple kinds of collections (lame example: suppose you have an array but also a map of SalesGroup, then SalesGroups would not be the best choice but you'd rather pick SalesGroupArray, SalesGroupMap etc.)


I think that makes perfect sense. Not specifying the type of collection means you're at liberty to change the implementation later, and clients can't rely on a particular implementation.


While it's not confusing, I think it is very easy to miss. If I were doing this, I would use something that stands out more, perhaps SalesGroup and SalesGroupCollection.


seems OK to me. just maintain your coding style throughout all your project.

0

精彩评论

暂无评论...
验证码 换一张
取 消