2 ms·
Why xml configuration files suck
I just started a new project, in Java because I was in a hurry, so I copied the web.xml from another project and just replaced the references to the old project with the name of the new project. (web.xml configures some things, like the servlets in the project, servlet filters, resources - many of them are needed for all projects).
Or wait - that was really repetitive. What do I do if something like that happens in normal code? I write an abstraction for it, something like configureServlet("newProjectName") would do, for example. Except with xml files I can't, or it would be rather complicated.
I conclude that it's probably a good idea to keep configurations in the same programming language as the rest of the project.
- run4yourlives 19y ago>in Java because I was in a hurry lol :-)
- Tichy 19y agoJust because I already know it.
- mrtron 19y agoI don't think you need to defend your choice of Java. It is hardly a poor choice to write software in. I worked with Java on a huge financial server, and it was really fantastic. That being said, .xml config files are something I strongly dislike as well.
- pcowans 19y agoHow would that work in Java (or any other compiled language)? You recompile every time you want to change the settings?
- Tichy 19y agoFor example, instead of saying "the configuration goes into web.xml", the servlet specification could have said "the configuration goes into ServletConfiguration.java" or something like that. Actually I think it Spring it can be done, have to look into it.
- rincewind 19y agoWith Java you can use BeanShell http://www.beanshell.org/intro.html http://www.beanshell.org/intro.html for the configuration files, so you don't need to compile at all.
- deleted 19y ago[deleted]
- twism 19y agoi dont know what you guys are talking about... I use spring and I just discovered embedded javascript (ala rhino) for view controllers and I'm in heaven right now... Can't wait to release to the public to test real world performance
- Tichy 19y agoCool, I was planning to use that, too. Is it availably with the latest version of spring? Last time I looked, they did not have javascript yet. Also, I think in Spring you can create configurations in a programmatic way, if you want to, you are not forced to use xml.
- bayareaguy 19y agoI conclude that it's probably a good idea to keep configurations in the same programming language as the rest of the project. Of course, if you used lisp you wouldn't even notice :-) XML is ok if nobody (other than the original developer or the person who takes over later) has to look at them. Lots of OSX apps use XML in .plist files and nobody cares because that's just a detail of the class library the devs use and an OSX app without a nice configuration panel is unthinkable. However, visible XML configurations are a symptom that your app is about to be assimilated into the borg collective.