Skip to content

Instantly share code, notes, and snippets.

@ilkerde
Created February 22, 2011 14:08
Show Gist options
  • Save ilkerde/838709 to your computer and use it in GitHub Desktop.
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.
using System;
namespace Is.This.A.Smell {
public static class EnumExtensions {
public static string AsString(this Enum e) {
return Enum.GetName(e.GetType(), e);
}
}
}
@dun3
Copy link

dun3 commented Feb 23, 2011

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