How do you do it?

Nate Bross

Contributor
Joined
Apr 6, 2005
Messages
601
Location
Chicago, IL
Are your data access methods smart enough to populate your business objects from a dataset or is your business object smart enough to populate itself from a dataset?

I'm wondering what you guys do, I tend to make my data access populate my business objects...

Thoughts?
 
I've recently started to use LinqToSql. So far, it has been working very well to automatically create business objects from the database tables.
 
I'm using XML as my primary data source, I have some complex clases to parse this XML and create datasets which I then have my data access basically repopulate into my own custom business objects.

The reason for this "double work" is because the XML, which I am not the author, has been known to introduce breaking changes from version to version...so I can't really easily go from XML to BizObject, the DataSet helps me keep keep changes to my code minimal.

What would you do in my situation?
 
I would tend to make my business object responsible for populating themselves from whatever underlying data source I am using. Personally I don't feel a data layer should have any real intimate knowledge of the higher level classes as this can create unpleasant dependencies.

Given your situation I would try and encapsulate the xml parsing and data set creation into it's own layer (with a standard interface if possible) and have my business objects deal with this abstracted layer. The layer may do nothing more than return datasets that my business objects load themselves from though.
 
Back
Top