A Funny Java Flavoured Look at the World

Thursday, May 04, 2006

properties/configuration files are just runtime factories

This probably isn't a revelation to anyone but I only really noticed this fact this week. I have been mucking about with hibernate and have been impressed how it uses configurations files as static factories. I don't know why but recently I have noticed that configuration files (usually xml at the moment) are excellent factories.
They can also act as a good base class or interface.
That's the beauty of configuration files you don't worry about their values until runtime where you can open them and retrieve the data from them. This allows you to add the ability to change their values after the source files have been compiled. They are particularly good at providing a dynamic way for users/customers to enter their own values without having to change any of the code.
They also make people create code that is quite abstract in a way because the information is hidden behind the name of the configuration file
Configuration files are used as a runtime/dynamic factory by Hibernate because you can retrieve many connection types out of them.
I know this is probably all well known by people but I had never really thought of configuration files in that manner until recently and I thought it was just something I found interesting about configuration files which I have been using for ages. It may make me consider what type of information I can put in there and maybe I could use them more in the future to achieve more flexibility.

It would be interesting to hear people's thoughts on the subject.

2 Comments:

  • If I read what you're saying correctly, then you've just come across the whole reason why Spring is successful.

    By Anonymous Anonymous, at Fri May 05, 08:00:00 pm 2006  

  • I have read articles which suggests that the reason why spring is so successful is because it has been built to be easy for people to add plugins and a choice of plugins.

    This probably means you have to use a fair amount of configurations files to allow this flexibility and to allow the plugins to fit into the configuration file. The configuration file is used as a type or interface which the plugins can link to.

    I think this type of framework will be a lot more popular in the future. It certainly fits to the programming rule "open closed principle". Where the piece of code is closed but can be extended.

    By Blogger The Hosk, at Sat May 06, 01:51:00 pm 2006  

Post a Comment

<< Home