aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Xml Vs Classes 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 "Xml Vs Classes" Watch "Xml Vs Classes" New topic
Author

Xml Vs Classes

Sid Bachtiar
Greenhorn

Joined: Feb 25, 2007
Posts: 8
Hi guys,

We are currently working on a framework that works based on request-response model. A 'controller' takes a request object and then returns a response object.

I raised an issue with the framework but it seems that may be I need to research this further, mainly for my own good. I went on to research on Google but didn't get anything. I'm really just curious on what the pros and cons of this two arguments.

The issue that I raised had to do with the fact that the request and response class are basically just Hashmap<String, Object> in disguise. The original developers thought that it is good because it makes the framework flexible, and that they will use Xml configuration files to validate the request and response. The Xml configurations will be cached in memory.

So for example for each task, we will have Xml configurations for validation of request and response objects at runtime. Their argument is that changing Xml is easier than recompiling the project when something change, which is a valid argument I think.

On the other hand I was arguing that we should make request and response class as interfaces and then implement request and response classes for each task with constructors to make sure that each request and each response has all the required information. And that the compiler will help the developers in enforcing this.

If anyone can make sense of my post, I'd appreciate any comment in regards to pros and cons of each approach.

Cheers.
George Stoianov
Ranch Hand

Joined: Jan 15, 2006
Posts: 94
Hello Sid,

I am not exactly sure from your post what the goal of this framework is? Is it a server for something? Is it a network server? What does it do at the end?

You are saying that you need to validate the request and response and they will actually be a hashmap in disguise. I assume you wish to validate the contents of the hashmap. and I assume that that is the payload of important data you are interested in, right?

I am going to use an example to illustrate my point here lets take an HTTP server and see the implications of your decisions in that context, since you have not provided one :
An HTML request and response need to follow a specific format so that browsers are able to read and process them. If you had a browser that was processing different types of inputs, therefore different request and response formats, lets say HTTP and FTP protocols then having a way to define the format at run time or declaratively is a good thing as long as your program will accomodate all possible variations...

Your arguement, to have interfaces to define the request and response, does not necessarily go against having xml files to validate the request and response as it pertains more to how you are going to handle this content (validate request and responses) in your code ... and if you suspect to change the request and response format and content you better have interfaces or you will be programming a pretty bug prone thing .

just me .02 cents
HTH
Regards,
george
[ April 24, 2007: Message edited by: George Stoianov ]
Sid Bachtiar
Greenhorn

Joined: Feb 25, 2007
Posts: 8
It's a general purpose framework that is being used at the moment for web services. Anyway, I think your example is very good there.

Originally posted by George Stoianov:
Hello Sid,

I am not exactly sure from your post what the goal of this framework is? Is it a server for something? Is it a network server? What does it do at the end?

You are saying that you need to validate the request and response and they will actually be a hashmap in disguise. I assume you wish to validate the contents of the hashmap. and I assume that that is the payload of important data you are interested in, right?

I am going to use an example to illustrate my point here lets take an HTTP server and see the implications of your decisions in that context, since you have not provided one :
An HTML request and response need to follow a specific format so that browsers are able to read and process them. If you had a browser that was processing different types of inputs, therefore different request and response formats, lets say HTTP and FTP protocols then having a way to define the format at run time or declaratively is a good thing as long as your program will accomodate all possible variations...

Your arguement, to have interfaces to define the request and response, does not necessarily go against having xml files to validate the request and response as it pertains more to how you are going to handle this content (validate request and responses) in your code ... and if you suspect to change the request and response format and content you better have interfaces or you will be programming a pretty bug prone thing .

just me .02 cents
HTH
Regards,
george

[ April 24, 2007: Message edited by: George Stoianov ]
 
Don't get me started about those stupid light bulbs.
 
subject: Xml Vs Classes