vendredi 15 mai 2020

Design Question - ORM vs OOP in Dot-Net 3-tiered app -should an object persist itself or only business logic layer should call DAL

I have an app that uses some business objects - like "User". I have a DAL layer that should deal with database calls.

Now I want to get User with Id 100 from the database. two options to do it:

Option 1: User user = new User(100); Option 2: User user = BusinessLogicLayer.UserBL.GetUserFromID(100);

In Option 1 - the User Class is "self maintained" but if I want to keep layer's separation - it needs access to the DAL layer and the DAL layer needs to be aware of this object (which kind of creates circular reference)

In Option 2 - the user Class is just a collection of properties. both business logic layer and DAL layer are aware of it - but it has no abilities on it's own (b/c it is being referenced by both but can't reference them).

What should be the preferred approach ?

Aucun commentaire:

Enregistrer un commentaire