This stackoverflow question has an interesting discussion on how to avoid giving enums and properties the same names so that you don't have code like this:
public SaveStatus SaveStatus { get; set; }
It seems the accepted answer suggested to use "State" for the enum and "Status" for the property:
public SaveStatus SaveState { get; set; }
But I think this is hard to read and not immediately clear what is what.
Since this enum naming problem is a constant issue, I am considering simply always suffixing my enums with "Enum" so I would have this:
public SaveStatusEnum SaveStatus { get; set; }
SaveStatus = SaveStatusEnum.Succeeded;
Does anyone do this? Happy with it? Solved this issue in another way?
From the MSDN page for Property naming guidelines:
Consider creating a property with the same name as its underlying type. For example, if you declare a property named Color, the type of the property should likewise be Color.
I'd take that as a "no" :)
Edit:
If you dislike using the fully qualified name inside the class that declares the property, you can work around it:
using SaveStatusEnum = MyNamespace.SaveStatus;
...
SaveStatus = SaveStatusEnum.SomeValue;
That way you can keep the enum name without the suffix, and limit the naming oddity to just that one class. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With