I've been seeing a lot of code recently that looks like this:
public interface IFoo { int Bar(); }
public static class Foo
{
public static IFoo Create() { return new FooImpl(); }
private class FooImpl : IFoo
{
public int Bar () { ... }
}
}
Basically, there is a contract defined by an interface, the the main business object class is a static class that provides factory methods, and there is an embedded class that provides the actual implementation.
There are some advantages to this pattern especially, the clean separation between the contract and the implementation. Still, it seems a little ugly to me: especially the naming of a static factory class with a business object name rubs me the wrong way.
My questions are...
1. Is there a name for this pattern or style of development?
2. What do you think about this pattern? Are there any other advantages besides a rigorous hiding of implementation? Is there a better way to achieve the same goals?