• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How to cope w/ high numbers of parameters

LumbergTech

Diamond Member
I am not looking for a philosophical argument, but a practical implementation.

I am receiving XML messages from a client and I need to process them on a server and return messages which contain quite a few values. The return messages will also be in XML and I do not have a choice to change this.

Once I receive a message, I parse the message and figure out the values that need to be sent in the return message.

I am trying to break out the code that creates the return messages into a separate class. So the server figures out what kind of message needs to be sent, and the values, but then another class should compile my XML message so that the server code is not incredibly cluttered up.

The problem I am running into is that I can receive a variety of messages. The responses have a format that shares some commonalities, but they also change to a fair degree.

What kind of class design can I use? Right now I am confused because I feel like I have a massive number of parameters that must be sent to the message building class for some of the messages that must be returned. I really don't want to do it all in the server because the code has become long and messy.

Right now I have a:

Server class that processes 1 message at a time
and also a Message building class that can generate the types of packets required

What is the best way to get the data to the message building class? OR should I be doing something else entirely?

For reference, the messages sent between the client and the server can contain up to like 30 values which are spread out between text fields in XML elements and attributes on those elements.
 
Last edited:
some solutions off the top of my head

- a setter method for each property
- a struct/class for the collection of properties
- a hash/array for the collection of properties
 
Overload the constructor for message class is one way.

Another would be to place all the parameters in a single object of data; pass that to the message builder class and have a massive switch statemetn to break out the building by message type.
 
Would it be possible to create an XSLT for each response type? That's how we handled the contents for each type of transaction email our systems sent. It could be passed the same object with values and selectively send the correct format based on type.
 
What method?

I am trying to re-create the server side for an application in another language without direct access to most of the code for the original server. I was getting a little ahead of myself and trying to write the code that generated the return xml packets before making sure I had the data structures in place to hold the data. I am working with another person on this project and our ability to synchronize our progress has not been good so far. It is a side project so it is constantly tossed on the backburner. I have now made classes to hold all the info and pass this to the XML packet building class so that they easily have access to the data they need to generate the xml.
 
Back
Top