torsdag 14 oktober 2010

In response to "Inducing The Great Divide"

I've been thinking (like a lot of others) about how to manage my application data, in my particular case it's been around config values. I need a backend to store and retrieve the data, some kind of object or interface for user code to read/write the data, and some user interface to manage it all.

I found a blog post (whose title is included in mine) about this topic which seems to have mounted some interest; including mine. But then, it struck me. The data aware controls available in vcl is a great framework for getting data around easily. Only drawback is, it expects a database as backend, which in many cases is unrealistic or overkill. I would like to use ANY kind of data source, not just databases.

Meet ASProvider. It is the start of a framework to provide the data from any TObject derived class. The provided demo isn't worth much (yet) - but the unit tests should show some of the potential.

Then with a TASProvider.ProvidedObject := TMyObject.Create;
TClientDataSet.Provider := 'ASProvider1'; //or whatever name was used
I will have the public properties of TMyObject as fields in the data set and a single record whose field data will be synchronized with the object. A data set refresh needs to be done to reload if the data in the underlying object is changed, though. Any changes made to the data set that is applied will be propagated to the object.

I've also made a ASCollectionProvider with support for multiple records (the Collection Items).
This is all young code, but I'm really pleased with it so far.