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?
The data layer manages the physical storage and retrieval of data. The business layer maintains business rules and logic. The presentation layer houses the user interface and related presentation code.
It acts as an interface between the user and the application. Business Logic Layer: It acts as an intermediate between the Presentation and the Data Access Layer. Data Access Layer: The layer at which the data is managed.
Data-Access Layer (DAL) Data-Access Layer is a layer in an application that provides easy and simplified access to data stored in persistent storage, such as an entity-relational database or any database for that matter. It is layer that exists between the Business Logic Layer (BLL) and the storage layer.
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.
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;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With