vb.net – Application layer references data layer directly

vb.net – Application layer references data layer directly

If you have a valid reason for calling the data layer directly, then do it. If you add a pass-through function in the business layer, then all youve done is added more code for no apparent benefit.

Now, if your business layer is exposed via an interface, IBusinessLayer for example, then adding a ProcessAllPersons() function to it and having it pass the call directly to the data layer makes more sense and consistency. This is what I would recommend.

the business layer should reference the data layer

This is one approach but arguably not the best if youre aiming at maximum decoupling between your modules and being able to change your data access layer easily without touching your business layer (this is called Persistence Ignorance).

Have a look at Onion Architecture and/or Hexagonal Architecture. These architectural styles emphasize on your business layer being at the core of the system and independent from any other layer.

Concretely, how it works is you define abstractions for data access objects in your business core, which will be implemented in peripheral modules and used by the application layer.




vb.net – Application layer references data layer directly

If you have no intention of changing your database provider and you have the ADO.net skills that a business layer would protect developers from, then you dont need a business layer.

However, where are you going to put your business logic?

Leave a Reply

Your email address will not be published. Required fields are marked *