R – Data Access Layer and Business Objects

data-access-layer

Not sure if I have the correct terminology, but I am a little confused on how to set up my 3-tier system.

Lets say I have a table of Users in my DB.

In my DAL, I have a UserDB class that calls stored procs into he DB to insert, update, delete.
I also have a UserDetails class that is used in UserDB to return and pass in objects.

So now I am not sure how to use this in my Business Logic Layer. Do I need another BLL object class for users? If so, would this not be redundant?
Or do I just use the UserDetails class throughout my BLL?

Best Answer

Look up a concept called 'Domain Driven Design' - the biggest thing there is using what's called a repository pattern (such as your UserDB class) as an adapter to the database, as well as a factory. Your business objects, or domain objects, then incorporate business logic into themselves and can handle interactions with other business objects.

What technology are you using? Something like ActiveRecord can probably help you a lot.

Related Topic