FilterOperators 或 FilterOperatorType - C# 中枚举的正确命名格式
哪种命名枚举器的合适(更易读)方式?您会考虑:
enum FilterOperators
{
IsEqual,
Contains,
StartsWith
}
class QueryFilter
{
FilterOperators Operator{get;set;}
}
var filter = new QueryFilter();
filter.Operator = FilterOperators.IsEqual;
可取?
enum FilterOperatorType
{
IsEqual,
Contains,
StartsWith
}
class QueryFilter
{
FilterOperators Operator{get;set;}
}
var filter = new QueryFilter();
filter.Operator = FilterOperatorType.IsEqual;
还是颜色或ColorType更
Which is the appropriate (more readable) way of naming enumerator? will you consider:
enum FilterOperators
{
IsEqual,
Contains,
StartsWith
}
class QueryFilter
{
FilterOperators Operator{get;set;}
}
var filter = new QueryFilter();
filter.Operator = FilterOperators.IsEqual;
Or is this preferable
enum FilterOperatorType
{
IsEqual,
Contains,
StartsWith
}
class QueryFilter
{
FilterOperators Operator{get;set;}
}
var filter = new QueryFilter();
filter.Operator = FilterOperatorType.IsEqual;
Also, Colors or ColorType?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
IrritatedVowel.com 建议如下:
因此,我相信首选是
FilterOperator
。IrritatedVowel.com suggests the following:
As such, I believe the preferred choice would be
FilterOperator
.《框架设计指南》中说:
所以我的建议是
过滤操作符
The "Framework Design Guideline" says:
So my suggestion would be
FilterOperator
我认为这就是就一个标准达成一致(你可以定义自己的标准)然后坚持它。我想说,附加“类型”似乎是个好主意,尽管对于像“颜色”这样简单的东西来说,它可能看起来有点愚蠢。它确实暗示它是一个枚举,我认为这很好。
我想说最后一个例子:)
I think it's all about agreeing on a standard (you can define your own) and then sticking to it. I'd say appending "Type" seems like a good idea, even though for something as simple as "Color" it might seem a bit silly. It does hint that it is an enum, which I think is nice.
I'd say go for the last example :)
这是非常主观的,但我首先想到的是“颜色”,它是一个包含多种颜色的列表,看起来很合适。但是,对于较小的列表,例如“FilterOperatorType”,“...Type”似乎比较合适。
简而言之,如果它们很多,那么该词的复数似乎是合适的,如果它们很少并且代表广泛的类别,那么“...类型”似乎是合适的。
This is extremely subjective, but the first thing that pops to mind is 'Colors' strikes me as a list of many colors and seems appropriate. However, for a smaller list, like 'FilterOperatorType', the '...Type' seems appropriate.
In short, if their are many the plural of the word seems appropriate, if they are few and represent broad categories the '...Type' seems appropriate.