想要改进这个问题吗? 更新问题,以便用
Closed 5 years ago.
我使用“这个”前缀已有两年左右(StyleCop SA1102 规则 ) 。 但现在我改变主意,用“下面”前缀来固定和实例私人字段,删除“这个 ” 前缀。
在这里,我的理由 从"这个" 转换为"下面":
- Breaks Easily: Nobody in your team will always use "this." prefix so when you see a project which followed this style you will not see "this." prefix for all instance members.
- Useless Distinguish: What is the benefit of distinguishing between instance and static fields? Do you ever gain anything of that?
- Noise : If you take care of using "this." prefix, you ll see "this" every where. For instance we had 77 times of "this" keyword in a class but after changing our style we just have 9 underscores and I think the code is more readable (you can easily follow the code logic).
- Razor: It seems ugly to use "this." prefix in the Razor C# codes. For instance you will have "@this.Html.Something" instead of "@Html.Something". And we like a general rule to apply on all of our C# codes everywhere.
你有什么想法吗?
忽略StyleCop SA1102规则(“ 此” ), 使用“ underscore” 前缀来区分分类字段是否合理?