File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes Automating via XML. Your opinion? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Automating via XML. Your opinion?" Watch "Automating via XML. Your opinion?" New topic
Author

Automating via XML. Your opinion?

Vladas Razas
Ranch Hand

Joined: Dec 02, 2003
Posts: 385
I see a lot of code (made some myself too) that use XML to "automate" or "make it easy" programming. In example we have standalone Swing UI, that has navigation tree, and multiple pages linked to each tree node. XML may look like this:

<navitem text="Setup" page_class="somepackage.SetupPage"/>
<navitem text="About" page_class="somepackage.AboutPage"/>

The program parses XML and creates user inteface. I can write, instead:

navtree.addPage("Setup", new SetupPage());
navtree.addPage("About", new AboutPage());

For me it looks the same. The later is even better:
a) no need for fancy UI builder.
b) no reflection. Which is nice when I hit CTRL+SHIFT+G on Eclipse to find all code that uses my class. And I can safely obfuscate my JAR.
c) it's much more easy to alter individual objects.

This kind of "automation" still requires individual pages coded. I can't just change XML and it will not start working unless I provide all those classes needed. I went that "XML automation" way before but now more and more I think it's not that good. It just creates jobs In short I am now against XML that will not change application behaviour without additional coding.

I would like to ask you, what do you think on this topic? Am I right or wrong and why?

Vladas
Vladas Razas
Ranch Hand

Joined: Dec 02, 2003
Posts: 385
Sorry my XML didn't make it to my post:

Vladas Razas
Ranch Hand

Joined: Dec 02, 2003
Posts: 385
Oh not again

navitem text="Setup" page_class="SetupPage"
navitem text="About" page_class="AboutPage"
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
You can have metadata for your screen/gui defined in database. You can generate the XML from the metadata using 3rd party tools. You can aswell realize the screen without even touching the XML route(if you have auto-generator for your gui)


Kishore
SCJP, blog
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
We used XML to generate Swing panels on the fly once when we had hundreds of tiny panels with a handful of entry fields on each. That avoided having hundreds of Swing panels in the classpath and loaded into memory and so on. I thought it worked out well in the long run.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Vladas Razas
Ranch Hand

Joined: Dec 02, 2003
Posts: 385
We had multiple panels too. It was problematic to layout components in pages using XML. I found VE (Visual Editor, Eclipse project) tool which generates code for page. So we can draw pages visually.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
XML is nice if you want to be able to change the behaviour of the system without having to recompile it - either by providing raw data, or by providing "plugin-information" (a la Dependency Injection).

It is often overused, though.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
bparanj
Greenhorn

Joined: May 27, 2002
Posts: 27
Originally posted by Vladas Razas:
I see a lot of code (made some myself too) that use XML to "automate" or

<navitem text="Setup" page_class="somepackage.SetupPage"/>
<navitem text="About" page_class="somepackage.AboutPage"/>

The program parses XML and creates user inteface. I can write, instead:

navtree.addPage("Setup", new SetupPage());
navtree.addPage("About", new AboutPage());

For me it looks the same. The later is even better:
a) no need for fancy UI builder.
b) no reflection. Which is nice when I hit CTRL+SHIFT+G on Eclipse to find all code that uses my class. And I can safely obfuscate my JAR.
c) it's much more easy to alter individual objects.

This kind of "automation" still requires individual pages coded. I can't just change XML and it will not start working unless I provide all those classes needed. I went that "XML automation" way before but now more and more I think it's not that good. It just creates jobs In short I am now against XML that will not change application behaviour without additional coding.

I would like to ask you, what do you think on this topic? Am I right or wrong and why?

Vladas


You are missing a major point of using XML. Externalizing data from the program offers flexibility. The module becomes open
for extension and closed for modification. It does not require re-compiling the code. Knowing how to effectively use XML is
also crucial.

In your case the implementation must automatically take the newly defined XML data and generate the GUI without requiring
any modification to the existing code.


Moderator : <a href="http://groups.yahoo.com/group/OOAD_UML/" target="_blank" rel="nofollow">http://groups.yahoo.com/group/OOAD_UML/</a> <br />Home : <a href="http://www.zepho.com" target="_blank" rel="nofollow">http://www.zepho.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Automating via XML. Your opinion?