JParrish wrote:
One of the reasons I like to use business entities over a dataset is that with the dataset you are still working with the data in a tabular fashion, which to me is less intuitive than an object hierarchy.
If you're using a strongly typed DataSet configured with relations connecting all DataTables, the intuitiveness of the data is pretty comparable to a custom business object.
If you had two business objects: Customer and Order, you might retreive the orders for a customer using the following code:
Orders orders = customer.Orders;
Whereas the same functionality, using a strongly typed DataSet, might look like this:
CustomersDataSet.OrderRow[] orderRows = customerRow.GetOrderRows();
Both scenarios are done with the same number of lines, both can be enumerated and accessed with strongly-typed properites, and both are arguably intuitive in their own ways.
The difference is that it took two seconds to create the strongly typed DataSet and the same coding style can be used across all instances of DataSets regardless what they represent. With DataSets, you can easily make changes to them, and send them back to your DAL which in turn easily updates the changes using a DataAdapter. With a business object, you'd have to develop that logic yourself, which seems pointless, and depending on where logic is placed, can be rather nasty (I've seen some rediculous code done by developers in this area).
JParrish wrote:
I also think that when properly implemented, a business entity can be more performant. For instance, a business object that represents a "customer" may have demographics, a collection of recent transactions made by the customer, etc. Using lazy load techniques the object is then optimized to pull only the necessary data for any given usage, and does so intrinsicly.
All that business logic you just mentioned is well-suited for an actual business logic layer, not the business object itself.
I use DataSets strictly as containers of data that are passed between layers and controls. Any events, methods, logic, ect that I need to perform is done externally to the DataSet.
I think the biggest factor that decides which route you take is the underlying architecture your applications use. In my case, DataSets make perfect sense. I like communicating with my business logic layer and letting it retreive the data for me as opposed to calling a method directly on the business object itself, so I develop everything into the respective layers, and leave the DataSets alone, existing only for the purpose of containing the data.