开发者

Abstracting the DataLayer (DAL) of a three-tier application

As continuation to my previous question, (see h开发者_C百科ttps://stackoverflow.com/questions/3737848/creating-a-loosely-coupled-scalable-software-architecture

Someone suggests to also Abstract the DAL like I abstracted the BLL from the Presentation Layer on my three tier project. Any suggestion on how to do this? Do I also need a factory between the BLL and the DAL? I need your input guys.. thanks.


Interesting - I'd put abstraction between the BL and DAL way before I'd do that for the presentation layer.

The approach used in your other question seems reasonable - why don't you just reuse that?

  • Yes you need a factory; but you can include this in a common class / assembly and have it just return a object, which you can then cast as it's returned - i.e: at the point in the BL where it's being called.
  • (for completeness:) using Activator.CreateInstance() (as you've used in your other question) is the right way to go.
  • For DAL I tend to use values stored in the config (as arguments to pass into the factory); it's not common to change the DAL implementation that often - so config works well for me.
  • Observe the Interface Segregation Principle (ISP) when designing the contractr / abstraction between the BL and DAL - if you do it right you'll be able to mix-and-match different physical DAL implementations at once.
  • If you keep the DTO's and factory in a common assembly (possibly the same one) then it's easy to re-use them with the BL and various DAL implementation - with the caveat that you keep this common class as devoid of dependancies as possble. If you do this you'll be able to add / udpate DAL implemenations without re-compiling and re-deploying the whole system.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜