Say I had a class that has a static factory method, like this:
public class Table
{
public static Table OpenTable(string path)
{
ITableFactory fac = IoC.Resolve<ITableFactory>();
return fac.OpenTable(path);
}
}
and a factory class that looks like this:
internal class TableFactory : ITableFactory
{
internal Table OpenTable(string path)
{
//Check the path
//Do some other stuff
//return a new Table.
}
}
Does this code smell bad to you?
EDIT: Another question: Is it a good idea to have a static method on the type that just forwards calls to the factory?
Some background: I used to have the TableFactory as public and make the user create a new one every time they needed to open a table but it felt like a long hall just to open a table. So I thought that I would make a static factory method on the Table class and make the factory class internal and just resolve it using IoC.