dataset vs business objects?

ScottyB

Active member
Joined
Jan 27, 2007
Messages
40
Location
Australia
Programming Experience
5-10
Hi All,

I generally use a datareader to read data from a database and input it in to a collection of custom business object(class), then use this collection to bind to a repeater or datalist on a webform.

Can anybody tell me if this is wrong. What are the pros and cons of using a dataset as opposed to collections of business objects?

Regards

ScottyB
 
Can anybody tell me if this is wrong. What are the pros and cons of using a dataset as opposed to collections of business objects?

If it better suits your application to have business objects rather than data containers, then do that. DataTable doesnt have any innate intelligence of its own, so it may not be a good chocie in all circumstances. In those situations, you might find that an object database rather than a classic relational one suits you better
 
Ok thanks,

Just a quick question, how do you know when it is most appropriate to use business objects over datasets, personal preferences aside?

Kind Regards

ScottyB
 
Erm.. usually when there is some complex processing of the data or you want to represent them in some way that doesnt sit well with a tabular data structure. As an example, I recently had to interface with a system written by a collective of nitwits who got the wrong end of the stick entirely when it comes to XML. Because the XML they had created was so convoluted and followed such crazy, stupid rules, I couldnt rely on serializing and deserializing a datatable so I had to build a custom set of objects that would serialize in such a way that the systems interop was possible, yet the object remained usable for our programmers (as an example, there are several nested layers of tags, and whether one tag in one nest related to aother tag in another nest was purely dependent on the order of appearance of both tags.. If there were two people, and two addresses, you could cause one person to "move house" just by altering the order of the name tags relative to the order of the address tags. Stupid, but thats how it was. Because I had a sepcial requirement to guarantee order, and I wante dto present names and addresses as uniformly linked, I built custom objects rather than just hack a datatable)
 
Ok Thanks,

Puts a lot of things in perspective for me. Its the first time I have had the this explained in this way.

In my career, I have seen people that use datasets and nothing but datasets, or people that advocate the use of objects and nothing but business objects.

Just goes to show that before starting a project as any just like any other trade we should choose the right tools for the job.

Regards

ScottyB
 
Back
Top