views:

291

answers:

3

I'm working on a small project where for the first time I want to use XML as the one and only data source...a file based store suits the need of the project.

When writing the DAL should I have all the get methods static? to aviod and "reading while file open" errors? Should I use CacheDependency on the file?

Thx

A: 

Is my question crap, boring or does no one have an opinion on it?!?

SteveCl
You should make the question a bit more specific, IMHO.
Sklivvz
with a face like that, maybe everyone is scared. :)
kenny
man, ur kiddin!! This is the results or seven operations!!
SteveCl
+2  A: 

I think you were not as clear as you could have been. How big are these files going to be? Would it make sense for the data layer to always keep the XmlDocument in memory and dump to harddisk on every update?

How often are updates going to occur, if at all? How are you going to handle concurrency? Are updates going to be transactional across multiple xml files? How are you going to handle consistency and transactional integrity? If there are no updates, your life will be much simpler.

Methods don't have to be static. The main thing to consider is that, in the future, you might want to change the DAL provider from XML to DB. To this end, the concrete implementation of the DAL interfaces should talk to an abstract data provider. For you, it would be an Xml provider initially, but you should be able to write a Sql Provider that implements the same interface and easily switch the implementation using dependency injection, config files or what-have-you.

One you have instances of the DAL implementations, you can just use those objects to talk to the data layer.

Hope this is a good start for you.

siz
A: 

OK.

The files are not likely to be huge, I would suspect the max to reach 1-2MB.

I get you with the DAL interface needing to be interchangable with a DB, so I need to think carefully about my interfaces.

Concurrency, well I am concerned about that and not entirly sure how I should handle it. I was thinking that static read and write methods would help.

The XML will be updated, not that often, maybe once a day, but it could be anytime and more often.

I am using a CacheDependancy to only get from the source when the file has changed.

Will i run into problems reading the Cache concurrently? So how do I deal with concurrency issues?

SteveCl