what is an elegant way to transform request to response?
In my app(server),I have incoming bytes(protocol) transformed into string.
Then I wrote my own grammar file and from there auto generate parser source code from compiler-compiler.This parser would then transform protocol into object using tree traversal,something like that.
Later I examined the object returned from parser and then using "if and else statements" to return response.
I have bad feeling using if else statements to do the job although I got the result I want.For example,it's too rigid and it's totally against oo principles of not modifying object internals.I'm thinking of using map and casting.But this is where I'm stuck at.Any hint or advice is much appreciated.
you could think of client sending http protocol to server and the server need to parse it and the select appropriate response based on request received before sending back response to the client.
I'm stuck at the part where I need to match response and request.Stuck here because I can't think of the most flexible and object oriented way as possible.