noodle22
Programmer
- May 8, 2008
- 23
Consider this example. Suppose that I have a Store object and a Product object. The properties in each class are
Store
-String Name
-String Location
-IList<Product> Products
Product
-Name
-ProductNumber
Now I am using some OR mapper to populate these objects. My current method of relating these objects is
-I have a namespace for the objects themselves
-And I have a namespace for database accessors that populate and make changes to the repositories of each of these objects.
So my database accessors might look something like
IStoreAccessor
-GetStore(int StoreID)
-Save(Store store)
IProductAccessor
-GetProduct(int ProductID)
-Save(Product product)
-Search(Store store, String productNameLike)
So, my question is should this search method actually be part of the IStore object (not IStoreAccessor)so that I can do something like myStore.Search("OO analysis & design book")? It seems like it could be harder for me to maintain database wise if I have a database access function existing as part of my entity, but, maybe it is how things are supposed to be done? I ask because I found an example project recently where that was the case (they included the search function in the IStore interface). If Search should go in IStore, then should Save go in there as well?
Store
-String Name
-String Location
-IList<Product> Products
Product
-Name
-ProductNumber
Now I am using some OR mapper to populate these objects. My current method of relating these objects is
-I have a namespace for the objects themselves
-And I have a namespace for database accessors that populate and make changes to the repositories of each of these objects.
So my database accessors might look something like
IStoreAccessor
-GetStore(int StoreID)
-Save(Store store)
IProductAccessor
-GetProduct(int ProductID)
-Save(Product product)
-Search(Store store, String productNameLike)
So, my question is should this search method actually be part of the IStore object (not IStoreAccessor)so that I can do something like myStore.Search("OO analysis & design book")? It seems like it could be harder for me to maintain database wise if I have a database access function existing as part of my entity, but, maybe it is how things are supposed to be done? I ask because I found an example project recently where that was the case (they included the search function in the IStore interface). If Search should go in IStore, then should Save go in there as well?