Simply speaking there are two diff systems which understand diff format. one system say XXX will send a message throg MQ in a line by line format .. now these line will have say diff keywords which will indicate the nature of the order and what is to be done on that order. and this will be parsed and understood and then converted into another format SAY to put it to YYY now this format is a string based format ( one full string ) of a specified bytelength . this is a two way kind where message has to be processed from XXX - understood - parsed - conv to YYY format and viceversa. then againg place it in MQ
there is no GUI involved only trf of message thro MQ from one system to another
I am going to think out loud here: what you need is a pattern that will do format transformation. So in that sense, you should try the Strategy pattern. You will have different strategies, transform format A to B strategy and transform format B to A strategy. Comments anyone ? Gavin
Thnx Don , Gavin i checked out strategy, but here i have one more thing to think of : there are fixed keywords that i need to map to which helps me in identifying values of those keywords in all the specific lines ( since message is sent in a lines format ) then i do the parsing using this mapping and convert it to a string and viceversa as DON mentioned it would be quite cumbersome to have it in a single file ... i wanted to seggregate into small pieces so that any change in format it becomes maintainable
Originally posted by Genie mani: there are fixed keywords that i need to map to which helps me in identifying values of those keywords in all the specific lines ( since message is sent in a lines format ) then i do the parsing using this mapping and convert it to a string and viceversa
I don't really understand this. You have a fixed set of keywords - fine. What do you want to use them for ? Perhaps a small example would help make it clearer ? D.
The actual transformation is of little relevance when thinking of extensibility here. If the input can be a bit different, it may as well be a lot different -> let's design accordingly. What I'm trying to get at is something like the following pseudo-code:
Now, for each new format you can write a new interface extending Transformer or just use Transformer and let the client code do the necessary casts if applicable.
PTS 1 the above will be a sample order which comes in form of lines VIA MQ there are several types of such orders , now each type is identified by specified Keyword like GTC 6th line will indicate simple order where as if it is CXL anywhere in the lines then it is a cancel order these are keywords to identify types then there are keywords or specific lines to be read for such type of orders its like we need a rules engine kind, when a simple order comes we know which lines to look for since it is given in the format specs , if its a CXL order then we know which lines to look for line 83.10 in line 6 is quantity etc... 1)so now i need to design a system which will read the format already known for such types where the line information is also read to extract the fields from the lines 2) then use this values and place it one after the other in a single string ( even this is format specified like 6th - 20th char will be quantity so the qty read from the above sample will be placed in this 6-20th char position. and then this entire process is reversed when i read a string from MQ and then convert it into line format given above.... hope this makes things clearer..... and thnx for ur replies once again...Lasse, DON [ May 21, 2003: Message edited by: Genie mani ]
So you're actually looking for something more like an implementation approach (how to parse the incoming message, how to detect the format of the incoming message, etc.) than a design pattern (how to support new formats without major changes)?
When the number of different tokens/keywords increases, you might probably want to refactor to something like a Map, mapping the Strings to different Strategy objects encapsulating the appropriate action done for it.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
thnx everyone for ur reply !!! actually its simple enough to have it in one single class and process the strings.. what i actually wanted was to have seperated functionality like the types i mentioned above i am using STRATEGY pattern this seperates the type as preuss mentions how can i work out processing these fixed token for conversion,are there any patterns for the same....
This guy is skipping without a rope. At least, that's what this tiny ad said: