views:

39

answers:

2

An app has a Foo class that is a concrete class with all business logic and behaviour properly defined.

That said, one need to get the collection of all the Foos that are persisted at this app.

Where should this "IEnumerable GetFoos()" method be placed?

Not at the Foo class itself, right?

+1  A: 

You will need a Foos class derived from CollectionBase, or a similar, to expose instances of your Foo class.

hmcclungiii
A: 

To obey SOLID principles you should think about real purpose of Foo class. As I dont know impementation details and internal workings of Foo I can not say much. But would not this design be more conventional ?

class Foo
{
  IPersistancePresenter persistancePresenter;
  public Foo(IPersistancePresenter persistancePresenter)
  { 
     persistancePresenter = persistancePresenter;
  }
}

interface IPersistancePresenter <T>
{
  IList<T> GetInstancesOf<T>();
}

Foo will not change (as it should not be Foo's responsibility) if later there would be another class than the Foo, that must be persisted and have instances collected at runtime.

rovsen