0

I am building a 3 tier architecture with a Presentation Layer (PL), Business Logic Layer (BLL) and a Data Access Layer (DAL).

I want to implement it in 3 different physical projects as follows:

  • PL Project -> Reference of BLL Dll
  • BLL Project -> Reference of DAL
  • Dll DAL Project -> No Reference

Applying the concept of IOC between the BLL and the DAL by defining interfaces and using DI via constructor injection will change the architecture as follows

  • PL Project -> Reference of BLL Dll, Reference of DAL Dll (for DI of concrete types to constructors of the BLL Objects)
  • BLL Project -> Reference of DAL
  • DAL Project -> No Reference

Ideally I want to achieve the following, while maintaining my IOC with DI.

  • PL Project -> Reference of BLL Dll
  • BLL Project -> Reference of DAL Dll
  • DAL Project -> No Reference

How is it possible?

Note : I don't want to use an IOC container.

Steven
  • 166,672
  • 24
  • 332
  • 435
sjj
  • 29
  • 8
  • 1
    I do not understand. DI and the IoC doesn't do anything with your dependencies. They just inject them. So what's your real problem? – jgauffin Nov 26 '12 at 09:43
  • i just don't want to reference DAL in my PL – sjj Nov 26 '12 at 10:01
  • Why do you do it then? `DI of concrete types to constructors of the BLL Objects?` that makes no sense? Maybe a real example of your problem? And how you solved it without DI? – jgauffin Nov 26 '12 at 10:05
  • Please check your question according to [this checklist](http://msmvps.com/blogs/jon_skeet/archive/2012/11/24/stack-overflow-question-checklist.aspx). TIP: Improve the formatting of your question. It sucks. – Steven Nov 26 '12 at 10:06
  • DAL with interfaces and concrete objects. BLL access the DAL.Dependency is injected from the PL to the BLL.For this DAL has to be referenced in the PL.How can i avoid this. – sjj Nov 26 '12 at 10:07
  • This question looks very much like http://stackoverflow.com/q/11338297/1528942 – Grégoire C Nov 27 '13 at 09:21

1 Answers1

0

You could split the bootstrapping of your DI into two parts. The first done in the PL project would setup the IOC configuration for objects implementing interfaces in BL and consumed by PL. The second part, written in the BL project would setup the IOC configuration for objects implementing interfaces in DAL and consumed by BL. You then need to make your PL project setup bootstrapper call the bootstrapper for the BL project as well as doing it's own configuration. You wouldn't have to reference DAL in PL if you do it like this.

Nick Ryan
  • 2,662
  • 1
  • 17
  • 24
  • Thanks Ryan.can you explain with an example or external link please. – sjj Nov 26 '12 at 10:16
  • Thanks Ryan.can you explain with an example or external link and please note that I don't want to use an IOC container. – sjj Nov 26 '12 at 10:22
  • @user1841186 my answer is operating on the assumption that you are using an IOC container. I would advise that you use an IOC container rather than writing your own code for this. – Nick Ryan Nov 26 '12 at 10:24