more flexible Factory interface

[email protected] Tue, 12 Apr 2005 22:54:37 +0300
Newsgroups gmane.comp.embedded.carlsbad-cubes
Message-ID <[email protected]>
Hello,

we started porting our application to swixml. So far it works just 
great. 
We haven't encountered any serious problems. Thank you for great tool.

May I make some proposals concerning code improvements. There is 
a method Parser.addChild(..). Why can't we introduce addChild method 
in Factory
interface like this

/**
  * @param parent component returned by newInstance method
  * @param child child component
  * @param index index of child as it appears in xml file
  * @param attributes child's attributes specified in xml
  */
void addChild(Object parent, Object child, int index, List 
attributes);

then we could have different factories for specific containers 
like JMenuBar, JScrollPane etc.

What advantages does it give to us. 
1. it makes code more object oriented by avoiding 
long if .. else if .. block in Parser.addChild method.

2. It would allow users to create their own custom gui containers and 
incorporate them into swixml by creating custom factories and 
overriding addChild method. 

3. We could have custom child's attributes which control add 
operation.
For example instead of XTabbedPane we could implement 
TabbedPaneFactory
with overridden addChild method and then xml would look like this
     <tabbedpane>
         <panel tabTitle="Tab1">
             ..
         </panel>
     </tabbedpane>
where tabTitle would be passed to Factory.addChild in attributes 
parameter.

What do you think about that?

Thanks,
Vitali.