What are the pros and cons of using XML to transfer data in this Java program? -


i've been asked write gui existing shell/cmdline program written in java, , want create layer of abstraction between gui , original program makes easy add different gui (a web interface, example, rather desktop application). @ moment, structure of program follows:

the command line options translated java hashtable (taking option such -f opt hash "-f=>opt". these options used set environment object, program uses.

the structure have in mind is:

following solid lines, means gui produces xml file holding same information shell/cmdline options, used set environment option.

the thing is, i'm not quite sure if that's best way things work (whence dotted lines, signifying alternative structures) , don't know if xml right choice here.

as stands, parts of program set environment object options located in same methods parts use environment results. easier implement fed shell/cmdline arguments directly program implement structure information passed through xml file. don't want create xml file , translate shell options , transfer program, might make more sense gui generate shell options rather creating xml.

the main advantage of using xml file far can see makes job of future developers easier can use existing libraries create xml files rather have worry getting -a opt1 -b opt2 -c opt3 [...] syntax right.

on other hand, i've heard trying create own xml language not taken lightly (though program stands stores data in xml files no dtd or schema far can tell).

is approach more or less right? or using inappropriate tools job i'm trying do?

in xml approach, taking user options, create xml, pass main program, parse xml , extract values set environment. these efforts unless passing options 1 process process or on wire (even in case can use json too)

if talking single process these options passed either through gui or command line, can encapsulate these parameters java object, populate using command-line / gui , pass main program. instance command line or gui -> populate environmentoptions object -> main program

and provide require abstraction, can create interface ienvironmentoption , use set required properties.

interface ienvironmentoption {     public static final string option_name = "-t";      public void setoption(string name, string value);      public string getoption(string name); }  class environmentoptions implements ienvironmentoption {     private properties envproperties;      @override     public void setoption(string name, string value) {         envproperties.setproperty(name, value);     }      @override     public string getoption(string name) {         return envproperties.getproperty(name);     } } 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -