Created
February 22, 2011 14:08
-
-
Save ilkerde/838709 to your computer and use it in GitHub Desktop.
I wonder whether introducing such an extension is considered a smell. For me it's most likely a smell.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Is.This.A.Smell { | |
public static class EnumExtensions { | |
public static string AsString(this Enum e) { | |
return Enum.GetName(e.GetType(), e); | |
} | |
} | |
} |
Most definitively a smell. But not the extension method itself, but the need for it and the use of Enum in a first place. This seems to no longer be a simple Enum and should most likely be replaced by a proper class(-hierarchy). We found that using an enum is often a premature optimization that will bite you in the end. Especially when decorating enums with attributes ... think very hard before going down that road.
Why did you use an enum in this case?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ilker: Man, that's what I call continuous improvement! ;)