Design Patterns for Erlang

Victor M. Gulias <>
Thu Feb 15 09:14:10 CET 2001

"Juan A. Suárez Romero" <> writes:

> Hi all.
> I've been programming with Java during last years, but at present I'm learning
> Erlang, and it seems very powerful.
> In the development of my Java applications I used the Erich Gamma's
> Design Patterns book; but the patterns that appear in it are very based on
> inheritance and polymorphism, issues that Erlang hasn't. 
> Somebody knows where could I find such patterns (or similar patterns) but
> applied to Erlang?

First of all, OTP behaviours represent Erlang design patterns as long
as they capture good solutions for common problems. Thus, I recommend
you the 'Design Principles' section on Erlang documentation to learn
about such standard Erlang patterns. In particular, 'gen_server'
behaviour is worth read (both documentation and source code).

In addition, most of GoF patterns (or variants) can also be
implemented using Erlang, even though there is no object-orientation
at all (who need objects? read Joe's comments about OO to understand
what Erlang people think of objects). In the large project that we are
developing at LFCIA, we have identified many problems that could be
solved using, for instance, factory methods, mediators, observers,
chain of responsability, and so on. Of course, in the implementation
you should wisely use the expresiveness of functional programming (who
needs to implement a factory class when you can define anonymous
functions to perform the same task?). In particular, our monitoring
system uses a monitor agent that performs the role of 'Mediator' to
implement a variant of the 'Observer' pattern, separating the actual
processing from visualization.

If this material is interesting for all of you guys, I can write it
down for Erlang PLI workshop or next EUC.


Victor M. Gulias

PS: Juan, I will include this material in my Ph.D. course on distributed
    functional programming. Of course, you are invited to attend -- just
    go upstairs (office 4.15)

More information about the erlang-questions mailing list