Yesterday I posted about the fun I have with EntLib and my initial reservations towards the Configuration Block and its support in the Console. Since then I spoke to Edward and Pascal and mailed with Dennis Mulder and they all didn't share my view on the uselessness of it. A good reason to revisit the problem, since I greatly respect their opinions.
Turns out they are more right then I thought. Although I'm still not a big fan of the Configuration Console (I felt like I had to build all settings twice, once for the data and once for the node properties), I now am a big fan of the Application Block model and it's configuration support.
Basically I made three mistakes when I played around with it. Yeah right, three mistakes. I'm getting too old for this software development, the time I could write a significant piece of code that compiled the first time seems lightyears away. Anyway, my mistakes where:
1) I build my testproject mainly around the designer, which is what you normally wouldn't do and made it harder to see the advantages. An understandable mistake to make, since it was the designer I was interested in.
2) I looked too much at the HelloWorld project, which is more complicated than simple projects need, because of the use of factories and providers. Also not a very bad mistake, they didn't write the sample to bypass it.
3) I saw my appblock as a settingscontainer instead of a piece of functionality. My biggest mistake. An Application Block is supposed to deliver functionality, how could I ever think about it as something that just stored my settings. As soon as I sorted that one out, I got the hang of it.
The example I used over and over again when I talked about configsettings was storing an FTP username and password securely for building an FTP session. I now realise that I should not only store the settings but build an appblock that hides all the complexity of building FTP connections. My demo FTP Application Block project was born.
An application block should have an easy to use API, in my case a GetFile and a PutFile that both accept a FTPLocationName as a parameter. This name maps to a location configured in the configuration file, with all the details like hostname, port, folder, username/password, etc. These settings are encrypted by the Configuration Block and stored securely. I had the skeleton running and configurable through the console in about 3 hours. So, I must admit, Edward, Dennis and Pascal are right, the configuration stuff in EntLib is cool, you should just use in the proper way.
BTW, to anybody interested in the FTP Application Block, I'm sorry to tell that I didn't implement the real functionality and the existing code contains numerous bugs, so you have to build your own I think.