locked
Repository Pattern Questions RRS feed

  • Question

  • User1696742691 posted

    I have been studying the Repository Pattern via the WSSF and MS's guidance package.

    I am still struggling with a few things regarding implementation and am looking for some guidance.

    1) It would seem to be overkill to create a repository class for each of my domain objects, yet I don't know of a good way around this.  Any ideas?

    2) Is it really necessary to create Selection, Insert, Update, and Delete Factories for each of the repository classes?  Is there a better way to abstract this?

    If anyone can point me to some examples or provide some suggestions that would be appreciated.

    Thanks in advance.
     

    Wednesday, March 12, 2008 10:35 AM

All replies

  • User-1038113095 posted

     Look at the Rhino Tools implementation for ideas, it simply works.

    Wednesday, March 12, 2008 11:30 AM
  • User1696742691 posted

    I'd also like to piggy back another question on to this as I continue to dig deeper.

    Consider the following scenario, I have DomainObjectA, which has a property of DomainObjectB.

    In my business logic layer I get a List<DomainObjectA>.  Where is the appropriate place to assign DomainObjectB to my newly returned DomainObjectA?  Would it by in my business logic layer?

    GetDomainObjectA

    foreach(DomainObjectA in List<DomainObjectA>)

    {

       DomainObjectA.DomainObjectB = DomainObjectA.GetDomainObjectB();

     }

    Or would it be in a factory class when I am originally constructing DomainObjectA.  I would then call my DomainObjectB repository GetById() method.  (Assuming I return the ID in my DomainObjectA selection factory).

    I hope that makes sense.  I'm really trying to get my head around this pattern as a whole and haven't seen a lot of examples or "best practices".

    Perhaps it's not as big a decision as I think it is and I need to find something that works in my specific domain.

     

    Wednesday, March 12, 2008 12:09 PM