Friday, August 27, 2010

VFE: Changing how system settings are stored.

Every so often I am still amazed at how awesome the VFE Framework really is. I hear a lot about YAGNI these days (you ain't going to need it) and how unnecessary features can be very wasteful. The following example illustrates how careful thought and design may save hours and hours of future development time.

I have a client who is having a lot of trouble with Users who run his app on Windows Vista and Windows 7. The problem is with access to the registry and all of the setting that VFE stores there. So, he asked me to modify the app to store these settings in a table. Now, we are not going to discuss whether a VFP table was the right approach or not. That would need to be a separate discussion. I began looking at the app and what I would need to do in order to change all of the system setting calls to read from and write to a table. I couldn't believe how easy it was. The following are the three steps. I had this feature completed far faster than I ever thought I would.

Step 1: Subclass cSystemSetting (or iSystemSetting) into a new class. I chose to put mine in the application layer but it could go in the iLayer just as easily. Get and Set are the key methods.

Step 2: Modify your new settings class to create the table, read from it and write to it. I also added code to delete and recreate the table/index if there were corruption problems. Since they are just settings, the client was fine with blowing everything away if necessary.

Step 3: Plug in the new system setting class through your application level factory table using the description of System Setting Manager.

That is all there was to it. I love this framework!