Traditional three-tier architecture and 3 tiers with IOC

I am creating a three-tier architecture with a presentation layer (PL), business logic (BLL), and a data access layer (DAL).
The usual three-tier architecture logic claims that the BLL should act as an intermediary between PL and DAL. A PL should not even know that there is a database, while a DAL should not know that there is a BLL or PL.

The implementation above will create the following dependencies between three different physical projects as follows

  • PL Project β†’ Link to BLL DLL
  • BLL Project β†’ Link to DLL DLL
  • DAL Project β†’ No Reference


However, applying the IOC concept between the BLL and the DAL by defining the interfaces in the BLL for the DAL to implement and use the DI through the constructor installation will change the dependency as follows

  • PL Project β†’ Link to DLL BLL, Link to DLL DLL (for DI specific types for BLL object constructors)
  • BLL Project β†’ No Reference
  • DAL Project β†’ Link to BLL DLL (for implementing BLL-interfaces)

So, IOC and traditional 3 levels in conflict?

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

  • PL Project β†’ Link to BLL DLL
  • BLL Project β†’ No Reference
  • DAL Project β†’ Link to BLL DLL

How do you do this?

+4
source share
1 answer

First you can split your layers using interfaces, and interfaces can be divided into dll partitions. Thus, each layer is dependent on the interface of the underlying layer.

I'm also not sure why you need to bind DAL with BLL? Is it for calls? Can't you use events instead?

Assuming all 3 levels are running in the process and assuming your PL is the β€œentry point” to your application (Root Composition), IMO is the usual dependency, if you separate the interfaces, with the bootstrap code in the PL, this is

  • PL => Links to BLL and DAL (concrete and interfaces) and IoC container
  • BLL DAL Links (or just an interface, if applicable)
  • DAL no Dependency (although this usually depends on DTO / POCO / Entities)

PL can offload the IoC configuration in the Bootstrapper dll, resulting in:

  • PL => Links to the BLL interface and bootloader
  • Bootstrapper => All links and IoC container
  • BLL => Links DAL Interface
  • DAL => No dependency (although usually it depends on DTO / POCO / Entities)

In some containers, you can avoid the need to reference all dlls from the bootloader using a configuration or convention . However, these DLLs obviously still need to be deployed with your application.

+2
source

All Articles