I'm wondering whether method overloading that will be mainly be there as convenience for the caller should be implemented on the interface or as extension methods? I've looked but I could not find any official guidelines when it comes to methods that are overloaded merely for convenience' sake.
I know that if you own the code you should probably not use extension methods but is there a difference when it comes to methods that are just there for convenience. I feel like they would clutter the interface but maybe that's just me.
Regarding duplicate: My question is more about method overloading when the overloads are there for convenience for the caller and will not differ between implementations
Example implementation with method overloading in the interface:
public interface IFoo
{
//This feels cluttered since they don't add any new functionality,
// they are just here to be convenient for the caller.
void Bar(int a);
void Bar(int a, int b);
void Bar(int a, int b, int c);
}
Example implementation with extension methods:
public interface IFoo
{
void Bar(int a);
}
public static class FooExtensions
{
public static void Bar(this IFoo foo, int a, int b)
{
//...
}
public static void Bar(this IFoo foo, int a, int b, int c)
{
//...
}
}