views:

57

answers:

2

Looking for some general advice here.

Option 1. Would it be best to have all of the main database objects (say Contact, User, Customer, etc. have their general classes in DAL with nested classes for db objects that depend on the main objects (ContactAddress, UserEmail, etc... these would have multiple values so they are contained in separate tables).

OR

Option 2. Would it be better to have completely separate DAL classes for things like ContactAddress, etc. and combine these elements in a business layer?

Let me know if I'm not making sense here.

+1  A: 

I usually define my objects in the business logic layer and do some translation between DAL objects and business objects. My DAL objects are usually autogenerated by some ORM framework (such as EF or LinqToSQL). The reason for this is that my business logic layer objects are not POCO's but also contains business logic, whereas the DAL objects are purely poco (although they may be decorated with some ORM logic).

klausbyskov
A: 

It usually aids in discovery if you put all public classes at the namespace level (instead of as inner classes).

The two examples you cited, could be generalized with no harm:

ContactAddress becomes Address

UserEmail becomes Email

This way, you can reuse them later if you wish.

Michael Meadows