[erlang-questions] Best practices in gen_fsm usage

Vance Shipley vances@REDACTED
Wed Dec 7 10:27:19 CET 2011

On Wed, Dec 07, 2011 at 03:13:59PM +0700, Maxim Treskin wrote:
}  So I need to pass behaviour with pid() of process to client.

Either that or use an accessor as Thomas described.

}  Putting state name in #state{name = StateName} of gen_server gives
}  necessary result.

Sure, go ahead and do that.  The gen_fsm behaviour is a tool to 
help you implement communicating finite state machines which is
a common design pattern encountered in the real world.  If you 
are working with FSMs but have no understanding of that you will
simply have a harder time conceptualizing the problem and it's 
solutions.  On the other hand if you do understand the theory you
can then make an informed decision on an implementation.

The fact is that if you tried to implement an FSM decribed in 50
pages of SDL you'd get lost pretty soon using a gen_server.  Or
not ... it's just syntactic sugar.


More information about the erlang-questions mailing list