views:

67

answers:

1

Hi,


Say DB has three tables: Customer, Order and Products. DAL layer could use just one class ( aka one data access logical component ) to perform CRUD operations on all three tables, or it could use three different classes (aka three different logical components):

1) Customer Data Access Logic Component
2) Order Data Access Logic Component
3) Products Data Access Logic Component


As far as I can tell, the only disadvantage of having three data access logical components ( thus having three classes ) is that BLL layer will need to instantiate(using reflection) three different class instances ( at DAL layer ) instead of just one?!


So what are some pros and cons of:
a) having three data access logical components?
b) having just one data access logical component?


thanx

+2  A: 

Nearly all of the applications I have seen use separate classes per DB table. This is also the way code generators typically work. Some reasons for this are: 1. you only need to instantiate objects for those tables you need to access, which has a smaller memory footprint (imagine a DB with 100 tables). 2. Code is more modular so that smaller pieces may be edited by different developers simultaneously.

Perhaps an advantage of having just one object is that less instantiations calls are required, but this is probably a negligible advantage for most applications, leading me to believe that the modular approach is usually better.

Lastly, you shouldn't need reflection unless you don't know in advance the names of your DB classes.

Trey
"you shouldn't need reflection unless you don't know in advance the names of your DB classes." I assume you do need reflection if you have multiple providers?!
SourceC