One interesting aspect of extension methods in .NET is the fact that you can apply them to interfaces. For me, it seems nice that I can define functionality near the interface without defining an abstract class that clutters the assembly.
I know that abstract classes are not obsolete or anything, but how do you feel about utilizing this side effect in your code?
Example:
public static class IUserExtensions
{
public static bool IsCurrentUser(this IUser user)
{
return (HttpContext.Current.User != null &&
HttpContext.Current.User.Identity.Name == user.ID.ToString());
}
}
public interface IUser {
int ID { get; set; }
}