[erlang-questions] Best practices in gen_fsm usage

Fred Hebert mononcqc@REDACTED
Wed Dec 7 13:58:05 CET 2011


I submit to you my trade_fsm system as described in my Rage Against the
Finite-State Machines chapter (
http://learnyousomeerlang.com/finite-state-machines)

http://learnyousomeerlang.com/static/erlang/trade_fsm.erl

Another one would be a player process I've got for Process Quest:
http://learnyousomeerlang.com/static/erlang/processquest/apps/processquest-1.0.0/src/pq_player.erlthat
one is a bit weird because it's a standalone process that sends itself
the events it needs to move forward.

While there's no doubt it would be possible to do with a gen_server, I
doubt it would be much cleaner or easier to read or as self-descriptive
written that way. Using a gen_fsm makes it more obvious how the process is
supposed to behave, in my opinion.

On Wed, Dec 7, 2011 at 4:40 AM, Max Lapshin <max.lapshin@REDACTED> wrote:

>
>
> It is exactly what Treskin was talking about. Show example of code,
> which is better built on gen_fsm, than on gen_server.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111207/a58e5117/attachment.htm>


More information about the erlang-questions mailing list