2

I am building as asp.net application on .net framework 4.0 and I will be using Linq to entities (Entity Framework) as my DataModel (DAL), my design pattern will be the 3-tier layers where the Entity Framework will be the DAL layer.

My question is should I have a BLL layer for my tables so that I deal with it from the presentation layer (my pages) where I call my select, insert, update and delete functions from or it is better to call the Entity Framework directly in my presentation layer?

Alex
  • 5,971
  • 11
  • 42
  • 80

1 Answers1

2

It depends on the application; layers are not defined because they are good, layers are defined because they are needed.

If your application is a big one and business rules are subject to change often, then go build a BLL layer. Otherwise, IMHO, it is just overengineering. The scale of your application and the rate of change should be your main concern when deciding.

Note that, if you call EF directly, your business rules will be inside your presentation layer. If they are subject to change, then refactoring the presentation layer will be a mess as well reusability will be lower.

But again it depends the scale of your application, your project schedule, the rate of change of business rules and other factors.

daryal
  • 14,643
  • 4
  • 38
  • 54
  • my application is a news portal and my concern is not to repeat the same methods like addarticle() for example 2 or 3 times where i can do a BLL layer for Articles and fill its properties then call the Addarticle() method which will do the rest of the work. – Alex Apr 05 '12 at 08:19
  • You may just define an addarticle method in the presentation and reuse it, this does not mean implementing a business layer. – daryal Apr 05 '12 at 08:21
  • you are totally right, but doesn't that mean i will have to modify this method 3 times for example if later i added a new field to the table? – Alex Apr 05 '12 at 08:24
  • No just use the same method of AddArticle in all needed places. If you change it, it will be changed for all. – daryal Apr 05 '12 at 08:32
  • but this will not change it in all places, if i have AddArticle() in a.aspx and b.aspx I will have to modify both then, I don't want this to happen – Alex Apr 05 '12 at 08:36
  • But in this case, I expect that the pages will also change. If addarticle method accepts a parameter of article, you do not need to change that? – daryal Apr 05 '12 at 08:42