Java Or XML for configs?

So I’m evaluating a new toy (tentatively titled SpringME) that does IoC bean wiring for mobile right? And I’m feeling a little twinge of N.I.H. which I try to fight off, cool? Cause I want to be the open minded person that treats all innovations equally without bias towards my own obviously superior attempts at solving the same problem. Anyway, I look at the toy and frown up because the author dared to forgo XML for bean configs in favor of Java syntax. I mean, c’mon! We all know that XML is the lingua-de-Frankfurt (mmmmm… Frankfurts…) for configing anything Java don’t we?Ya’ with me here? Well guess what? I’m starting to think that maybe XML isn’t what it’s cranked up to be? Why do we always resort to pointy-brackets whenever we need to externalize an idea?

I’ll tell you why! It’s because we don’t know better. We’re raised from birth and told both to eat our broccoli and terminate our nested <thoughts> with a matching </thoughts>. We attend public schools where XML prologs and DTDs precede the singing of the national anthem. (Don’t blame me, blame your local school district!) Then to top it all off, instead of teaching our kids the gospel according to Luke we over indulge them with the magical wonders of Xerces. What else is a Java dude to do in this day and age? Angle bracket are enforced by our government as the answer to all problems. Even our president has considered augmenting our troops over seas with additional processing instructions and supplementary schemas. (Ok, none of the above actually makes any sense but I am arriving at a point somewhere in this text.)

The point is this… configuration really doesn’t have to be done in XML. I mean yeah, XML is cool and all. It makes you feel good everytime you auto-complete a tag in Eclipse. But what do you really get out of it other than the fact that its a mainstream syntax? What’s wrong with leaning on Java syntax or even a properties file for configuration? Where did all the true Java roughnecks run off too? Holla if ya’ hear me! In my day [story-of-experience age-of-narrator=”31″ voice=”old, shaky, and withered” long-winded=”true” legacy-technology=”involved” point=”lost”]
we would write these oooold RPG programs. They were tied to something called a DDS file which was your screen layout. Whenever we wanteed to externalize something we had these fine-n-dandy data areas. A guy could put anything in the dang data area and the value could be pulled into either the RPG code or even the DDS if I’m not mistaken. There weren’t no danged close data area thingies er none of this new fangled nonsense the youngin’s are into today. Just raw external configurations. Sometimes we wuld get fancy and create a PF (that there is uh Physical File) to hold our doggone data. Now that’s configging!

Where was I? Oh yeah! XML, do we really always need it? Is it really the answer for crime and low income families in Philadelphia? Is there something that we’re all missing? Talk to an old war torn developer and remind yourself where you came from. Hit me up people…

3 thoughts on “Java Or XML for configs?

  1. I spent several weeks wrestling with XML config files and Jetty for one project. I finally gave up on it when I got sent to the east coast for a few months (different project) and came back to find an unreadable mess.

    I’d much rather go back to properties files, but if something has to have an XML config file, at least it should have clear documentation on how to edit the files to affect application behavior as desired.

    Listening to Kanye West’s Graduation as I write this.

  2. Yo, Cliff, I happened onto your blog & before I know it I’ve spent an hour grokking it. A whole buncha stuff is right up my alley. I’ve got mad Java skillz and can relate to what you’re saying on a lot of topics.
    So about xml…so what’s up with xml everywhere? My philosophy with xml as well as a lot of things is, it’s not inherently good or bad, it’s how you use (or abuse) it. If you think “I’ve gotta have xml configuration” and you write a whole bunch of grungy JDOM code that you have to update everytime you add a property, then that’s wack. I prefer tools (such as XStream or Spring) that will just grok your JavaBean and do the Right Thing. Hey, we’re at Java 1.6 and we’ve had introspection in Java since 1.1. I’ve done some way cool stuff with reflection and dynamic proxies but it seems most developers still think they’re in C++ and have to add methods every time you want to get at a new property. You all know who I’m talkin’ about?
    Hm, where was I getting to? Well, Spring is one of those tools that uses XML right, in my opinion. It’s dynamic out the yin-yang, so give it a chance. You can expose all your configuration and you don’t have to write any extra grungy JDOM code to slurp it all in. Spring has a pretty consistent philosophy that makes a lot of sense, and I guess you could say I’ve been partaking of the kool-aid.
    BTW, I’m originally from philly area myself…well, close (Bethlehem) anyway…but now reside in Oaktown, as in CA (OBD stands for Oaktown Baby Daddy).

  3. OBD,

    Wassup cousin! Yeah I got’cha. I’m not saying that XML is good or bad either. I’m just saying that there are options. Options which could sometimes be more appropriate given your situation/environment. In my case I work with a team of guys who’ve never touched Spring so using Java syntax to wire everything up could work a little better… even as much as I wanna go whole hog with my Spring-ish Fallframework. This topic was all about my coming to terms with that reality. I dunno, I kinda feel like waffling back and considering XML again. The main reason is because it forces you away from imperative-like constructs. For eg., using Java syntax for configs would allow the use of mutable variable assignments and loops and all kinds of order sensative stuff. On the flip side XML would force you to unwind your mind and do the right thing, declaring beans and listing their dependencies. I don’t know if ya’ still following that but no doubt it’s going somewhere. I’m gonna be doing something about our bean wiring in the next couple of days so watch for updates. Oh yeah, and thanx for hanging out! If ya feelin’ me tell a friend to tell a friend. Then tell that friend to tell his momma (cuz sometimes moms need to get their XSLT on!) A lot of this stuff is nonsense but every so often I put something kinda useful out.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s