Do you allow the Web Tier to access the DAL direct

2019-01-21 17:17发布

I'm interested in perceived "best practice", tempered with a little dose of reality here.

In a web application, do you allow your web tier to directly access the DAL, or should it go through a BLL first?

I'm talking specifically of scenarios where there's no "business logic" really involved -- such as a simple query : "Fetch all customers with surname of 'Atwood'". Scenarios where there's any kind of logic absolutely are gonna go through the BLL, so lets call that moo.

While you could encapsulate this method inside a BLL object, it seems to be somewhat pointless when often the signature will be exactly the same as that of the DLL object, and the code probably as simple as a one liner delegating the query off to the DLL.

If you choose the former -- employing a BLL object -- what do you call these objects? (Assuming they do little more than provide a query layer into the DLL). Helpers? QueryProviders?

Thoughts please.

Regards

Marty

7条回答
走好不送
2楼-- · 2019-01-21 18:19

We've tended to use the facade pattern for access, though our project that we use it on is sizable, I think it may prove overkill on a smaller project.

Essentially:

UI -> BusFacade -> BusinessLogic -> DalFacade -> DataAccessLayer

the facade makes for a nice/clean approach from the UI, and forces you to standardise on your naming conventions as that single point of entry has a number of methods.

BusFacade.GetCmsSiteMap()
BusFacade.GetProductGroup()

etc.etc.

查看更多
登录 后发表回答