开发者

XRef vs Xref (.NET naming)

Which name is more consistent with .NET naming standards for properties and methods?

1.

publ开发者_如何学Goic string XRef { get; set; }

2.

public string Xref { get; set; }


I would say the first - the "X" is effectively a separate word (cross). This is a bit like the CData class (and XCData). It does look a bit odd, but I think it's worth indicating that the "R" is effectively the start of a word.

On the other hand, for a variable I'd probably use xref rather than xRef, simply because that latter looks really weird.


According to the Design Guidelines for Class Libraries (http://msdn.microsoft.com/en-us/library/ms229043.aspx), I believe you'd end up with XRef.

  1. X is not an acronym (acronym must be two or more characters)
  2. XRef is not a compound word or common term.
  3. Therefore, the Capitalization Rules for Identifiers comes into play. That says use Pascal casing. That would say capitalize the first letter in the identifier (X) and the first letter of each concatenated word (Ref).

I think, in the end, it really depends on what your coding standards are.


It depends on your code conventions, I think. I'd write XRef because xref is not one word, it contains X and Ref, and each word we should start with upper case letter.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜