i ask myself if it is a good design if an extension method uses
another in the same extension class.
public class ClassExtensions
{
public static bool IsNotNull<T>(this T source)
where T : class
{
return !source.IsNull();
}
public static bool IsNull<T>(this T source)
where T : class
{
return source == null;
}
}
EDIT
Thanks for the answers.
And sorry for the bad sample.
It’s fine. Your example is a little trivial, of course, but consider other situations where a method could provide overloads (using string.Substring as example… pretend method doesn’t already exist).
Calling overloads obviously allows you to keep your logic centralized as much as possible without repeating yourself. It is true in instance methods, it is true in static methods (including, by extension, extension methods).