State pattern query
- From: gordon.is.a.moron@xxxxxxxxx
- Date: Sun, 29 Jul 2007 03:40:28 -0000
Hello,
I'm attempting to use the State Pattern as described in the GoF book.
I have two states, send and receive, each will either call low level
send or recv depending on what command comes in over the sockets.
However, I've noticed using the pattern that I have to call the
original interface function from the Context class. This means when I
receive data in the Receive State subclass I have to return it all to
the calling function in the context class, then call that context
class method again so I can change the state, having to pass data back
down to the Send State subclass so it can send it out over the socket.
This seems a bit too complex. The trouble is I don't simply
send,receive,send,receive, it may be that I have to receive, send,send
etc. So I need to make sure it's done in the right order. Maybe for
now I should just use a map (which I'm using for the state transitions
anyway) and simply parse the command and use the map to decide whether
to send or receive? Any advice?
Thanks,
Gordy
.
- Follow-Ups:
- Re: State pattern query
- From: Kevin Mangold
- Re: State pattern query
- Prev by Date: How do I start?
- Next by Date: Re: How do I start?
- Previous by thread: How do I start?
- Next by thread: Re: State pattern query
- Index(es):