我应该如何命名一个描述字段是隐藏、可选还是必填的枚举?
我有一个带有一堆字段的控件,我希望用户能够配置它们。
我最初有这个:
public bool Phone1Visible;
public bool Phone1Required;
然后意识到我不想处理必须再次验证隐藏的必填字段,所以我想出了这个:
public enum YOUR_NAME_HERE
{
Hidden,
Optional,
Required
}
你会命名这个枚举吗?我在想“FieldCriticality”,但这听起来有点罗嗦。
欢迎提出建议。
I have a control with a bunch of fields that I want a user to be able to configure.
I originally had this:
public bool Phone1Visible;
public bool Phone1Required;
Then realized that I didn't want to deal with having to validate again hidden required fields, so I came up with this:
public enum YOUR_NAME_HERE
{
Hidden,
Optional,
Required
}
What would you name this enum? I was thinking "FieldCriticality", but that sounds a little wordy.
Suggestions welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
我会使用 FieldState。
I would use
FieldState
.FieldMode
怎么样?我认为“模式”有助于传达这与字段的值或用户当前与其交互的方式无关。How about
FieldMode
? I think “mode” helps convey that this isn't to do with the value of the field, or how the user is currently interacting with it.我将使用 FieldValidation 作为您希望如何使用此枚举的描述性标题。
I would use
FieldValidation
, as a descriptive title of how you wish to use this enum.我会选择 FieldType
I would go by FieldType
我会使用 FieldProperty 或 FieldAttribute
I would use FieldProperty or FieldAttribute
也许
FieldModifier
或FieldInteraction
适合您?Maybe
FieldModifier
orFieldInteraction
would suit you?状态
就这么简单。
然后你会得到
看起来非常具有可读性和解释性的信息,特别是在使用 Intellisense 弹出时
Status
As simple as it gets.
Then you'd get
which seems very readable and explanatory, expeciaally when popping up with Intellisense
我只是花了一些时间思考这个问题并最终得到:
因为最终我会使用这些信息进行验证。我觉得“FieldType”等建议更多地指的是字段内部类型(文本字段、复选框字段)。
I just spent a while thinking about this problem and ended up with:
because in the end I would use this information for validation. I feel that the suggestions such as "FieldType" refers more to the fields internal type (text field, checkbox field).
我经常将
InputPolicy
用于这样的枚举。I often use
InputPolicy
for enums like this.