Thread: what is an elegant way to transform request to response?

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    71

    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.
    thanks

  2. #2
    Registered User
    Join Date
    Jul 2008
    Posts
    71
    Nvm,found the answer for my problem.This is for anyone else in the future who is facing the same problem...

    http://coffeecokeandcode.blogspot.co...y-pattern.html
    http://www.gamedev.net/reference/art...article841.asp

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you check what is wrong with this code
    By Ron in forum C++ Programming
    Replies: 4
    Last Post: 08-01-2008, 10:59 PM
  2. Socket Programming Problem!!!!
    By bobthebullet990 in forum Networking/Device Communication
    Replies: 2
    Last Post: 02-21-2008, 07:36 PM
  3. Sorting out cause of wrong response from class members
    By imCrushedByCode in forum C++ Programming
    Replies: 11
    Last Post: 04-18-2006, 12:30 AM
  4. returning char arrays!!!!
    By bobthebullet990 in forum C Programming
    Replies: 2
    Last Post: 03-30-2006, 07:05 AM
  5. No response from Google
    By jmd15 in forum Networking/Device Communication
    Replies: 2
    Last Post: 09-06-2005, 04:19 PM