views:

44

answers:

3

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

1.

public string XRef { get; set; }

2.

public string Xref { get; set; }
+3  A: 

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.

Jon Skeet
+1  A: 

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.

Pavel Belousov
+1  A: 

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.

Paul Kearney - pk