When adding a new WCF service in a project, Visual Studio creates the following two templates (namespaces and comments removed by me for brevity):
[ServiceContract]
public interface IMyService
{
[OperationContract]
void DoWork();
}
public class MyService : IMyService
{
public void DoWork()
{
}
}
Following YAGNI, I usually immediately simplify it to
[ServiceContract]
public class MyService
{
[OperationContract]
void DoWork()
{
}
}
based on the assumption that there's always going to be only one class implementing that interface and there's no obvious advantage of typing everything twice. If, for some strange and unforeseen reason, there will be another implementation in the future (or I want to use the same class for two services), I can always extract the interface(s) later when I need it. After all, my contract with the outside world is WSDL, not the interfaces in my code.
However, I'm always skeptical when going against best practices recommended by Visual Studio, hence I'd like to ask the community:
Is there some obvious advantage of splitting the interface and the class of a WCF service right from the beginning that I'm missing?