Here is how I see the main differences between the DAL and the BLL:
- The DAL directly query the database.
- The DAL doesn't create new information. It may execute complex sql requests, joining several tables, but the result of such a request never gives any information that wasn't already in the database.
- The BLL applies a business logic on the DAL's informations to create new informations.
Now, I wonder what datatypes these layers' functions are supposed to return. For the moment, all my DAL's function return DataTable. But my BLL's functions return some class or list of class that I created.
For example:
- dal.getAllPortfolios() returns a DataTable (I'm working with Visual Studio), result of a join on several tables.
- bll.getAllPortfolios() calls dal.getAllPortfolios, but return a List of Portfolio. With my public Portfolio class being in the BLL's namespace.
Sometimes, the BLL function doesn't really apply any "business logic" but only map the DataTable from de DAL into a BLL's class.
I wonder if this is ok. Maybe all the mapping work should be done by the DAL? If this is the case, where to put my personal mapping classes? In the BLL or DAL namespace (those classes being required in layers above the BLL)?