[Design the new POJO MicroContainer] - Re: MC tools
by flavia.rainone@jboss.com
"alesj" wrote : I would also handle different metadata classes/values differently, more OO.
| As it would be much easier to extend (and support) in the future.
|
| Every excessive "if" usage usually indicates lack of OO. ;-)
This is the case when you can edit the types you're dealing with and add a method to them to do what you want to do. So, instead of doing:
CommonSuperClass obj =...;
| if (obj instance of A) { System.out.println("A blablabla"); }
| else if (obj instance of B) { System.out.println("B bla bla bla");}
You change A and B classes to:
| class A extends CommonSuperClass
| {
| ...
| public String getMessage() { return "A blablabla";}
| }
|
| class B extends CommonSuperClass
| {
| ...
| public String getMessage() { return "B bla bla bla";}
| }
And now you can do:
CommonSuperClass obj = ...;
| System.out.println(obj.getMessage());
But, of course, I can't change the meta data classes, adding a method that generates the XML form of each one of them. So, how can I get rid of my if instanceof statements and still generate proper XML for every meta data type?
I guess I missed what you're trying to tell me. So, please, elaborate :)
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4237302#4237302
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4237302
16 years, 7 months
[Design the new POJO MicroContainer] - Re: MC tools
by flavia.rainone@jboss.com
"alesj" wrote : Looking at the JBossBeanXMLMarshaller::marshal.
|
| | else if(value instanceof BeanMetaData)
| | {
| | BeanMetaData anonymousBean = (BeanMetaData) value;
| |
| I guess a recursions could be used here?
It shouldn't, unless you want to make the code less clear.
The method that receives the BeanMetaData does not deal with anonymous beans, as is the case of the internal bean. Plus, the internal bean is much simpler, it can only have properties.
I think that the point here is that I wrote the code converting ServiceMetaData to BeanMetaData counting on using JBoss XB marshalling. This marshalling would validate my bean meta data (I'm absolutly sure that this meta data I'm generating is not correct, if I passed it along to MC it wouldn't interpret all the meta data the same way I'm doing it).
Now, that discovered that I can't use JBoss XB marshalling:
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4234012
I think that converting meta data is pointless, IMO. I'm considering to get rid of that convertion and to generate the XML directly, based on ServiceMetaData.
What do you think?
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4237296#4237296
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4237296
16 years, 7 months