views:

161

answers:

2

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?

+2  A: 

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.

Luke Schafer
+1  A: 

You typically would enforce Business Rules in your BLL. For example, you might allow regular call center employees to offer a 10% discount on new service but allow a manager to offer a 20% discount. You would have a business rule in your BLL that goes something like:

// Pseodocode
double Discount
{
    set
    {
        if (value > 10% AND Employee Is Not Manager) then throw Exception
        if (value > 20%) then throw Exception
        discount = value;
    }
}
Eric J.