"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#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...