Sunday, March 20, 2011

Should I Create a Business Logic Layer?

The Business Logic Layer (BLL) is located between the Data Access Layer and the User Interface.  This is where your data is traslated from Database objects, like DataTables and DataRows into Classes and Objects.

Sometimes I use them, and other times I don’t.  This should become obvious in your design phase, when you learn whether or not your application is manipulating data after retrieving it from a database.  If your application is CRUD (Create Retrieve Update Delete), then most likely you don’t need a BLL.  It would be a waste of your time to add an unnecessary layer just because it is a “Proper Model”.

I find that with the Entity Framework the need for a business layer is further diminished.  The reason is that the auto generated code, that is the Model, takes out the need to translate DataRow to an Object.

Now, the only reason left to have a business layer is for business logic.  This is were much of your common code may go, like generation of reports, charts, and calculations.  The last few projects I have done only had partial business logic layers.  I only created them when necessary.

No comments:

Post a Comment