baileyswalk
baileyswalk

Reputation: 1228

Data Access Layer returning BusinessObjects

Currently I'm researching the best design pattern to implement for a windows form application using VS2010 in VB.

I'm getting a bit confused with some design patterns. I understand that the DAL should return objects and not datareaders, datasets etc. but... if I have two functions in my DAL: GetProductById & GetAllProducts

These two functions would return a Product object and a collection of Product objects respectivley. Would Product not be a BOL object?

If I add CRUD into this object then it can no longer belong to the BOL do you have two versions of the object, one for DAL & one for BLL without the database methods?

I know there are similar posts on here but they have only served to confuse me further, is it possible someone could just explain in simple terms how DAL objects interact and differ from BOL objects.

Thanks.

Upvotes: 1

Views: 625

Answers (1)

J. Ed
J. Ed

Reputation: 6752

the scenario you've described is just fine- your DAL should return business objects (or, to use MVC terminology- model objects).
the model objects are a different 'layer', with which both the controller layer and the DA layer interact.
your CRUD methods can also go into the DAL (SaveProduct() or DeleteProduct() etc.)

Upvotes: 2

Related Questions