[LC++]State Machines

Paul M Foster paulf at quillandmouse.com
Fri Dec 14 16:08:04 UTC 2001


On Wed, Dec 12, 2001 at 02:06:04PM -0500, Jack Lloyd wrote:

> If you have access to a copy of Design Patterns, check out the "State"
> and "Interpreter" models. The State pattern does almost exactly what you're
> suggesting. Also the Flyweight pattern to reduce memory usage would
> probably come in very handy.
> 
> I would say it's an interesing idea that could be fairly practical. -J
> 

Grrr. This is like the 50th time someone's recommended that book. Okay,
so I went out and bought it. Tough slogging, as I'm not an expert at
this, but a pretty good book.

Thanks,

Paul


> On Mon, 10 Dec 2001, Paul M Foster wrote:
> 
> > I'm just playing with some ideas here, and looking for feedback. Anyone
> > ever heard of doing a state machine as a set of classes, with each state
> > as a separate class? I'm thinking about parsing a file containing
> > keywords and parameters. (Yes, I know you can use lex and yacc for this;
> > I'm just kicking around ideas.)
> >
> > I haven't fleshed this out fully in my mind, but there might be a base
> > class that has a get_next_token() method. Each class inherits from the
> > base class and handles a specific state. The state class object would
> > process whatever it needed to, and then have a next() method that called
> > the get_next_token() method, interpreted the token, and determined what
> > the next state would be, etc.
> >
> > Is this a really horrible idea? Intriguing?
> >
> > Paul
> >
> > _______________________________________________
> > This is the Linux C++ Programming List
> > : http://lists.linux.org.au/listinfo/tuxcpprogramming List
> >
> 
> _______________________________________________
> This is the Linux C++ Programming List
> : http://lists.linux.org.au/listinfo/tuxcpprogramming List



More information about the tuxCPProgramming mailing list