I'm not sure which of these two "patterns" is the best. Currently I use option A (in conjunction with a provider for implementing persistence), but I'm now erring towards B, especially in light of unit tests being able to use the "dependency injection" model.
Option A:
class ClassA
{
ClassA() { }
Save();
static List<ClassA> GetClassAs();
}
Option B:
class ClassA
{
ClassA() { }
Save();
}
class ClassARepository
{
ClassARepository() { }
List<ClassA> GetClassAs();
}
I think what I'm asking is, is it good practice for a class to expose static methods that return collections of instances of itself?
Edit
There seems to be a general consensus that Option B is the better choice. Looks like I have plenty of refactoring ahead :S