Erlang Extreme Programming & Refactoring, Was: non-telecom in erlang
Wed Feb 5 15:13:50 CET 2003
Erlang really is agile.
FutureSource is using Erlang in an XP development environment. After doing
this for a few months I am convinced that Erlang + Extreme Programming is
the proper way to do software in our domain. Our domain is real-time market
data analysis software and trading.
> What tools do you use for unit tests and acceptance tests?
Erlang Unit Tests (our approach)
We use Erlang for developer tests since they are the simplest thing that
could possibly work to test Erlang fully including the synchronization
multiple processes. Each Erlang module has a partner _test.erl module. And
each _test.erl module exports a single function all/0 that simply runs all
We rely solely on Erlang's powerful pattern matching to generate exceptions
that stop the unit test. So most of our unit tests look like this:
all () ->
ok = test_addition (),
ok = test_subtraction (),
test_addition () ->
A = 1,
B = 1,
2 = A + B, %% if there was a problem then this would exit with a
This keeps the 1000s of unit tests from generating noise unless something
really breaks and so it is easier for us to fix things quickly because we
see only those things that break.
Erlang Acceptance Tests
We use our own scripting language interpreted by a Perl script for the
acceptance tests. We do this so it is easier for the cutomer to "get it".
The scripting language is just a long list of simple commands with the
customer's queries and expected data. The Perl underneath that is where we
can code up some rather complex relationships among Erlang nodes.
> What does it feel like to do refactoring in Erlang?
Obviously you cannot use the C++ or Java cookbooks; one must understand the
patterns and apply them. There are many things like MoveMethod and
RenameClass that fit well if you develop Erlang modules as ActiveObjects.
InnapropriateIntimacy is there. And One handles this by extracting a new
Refactoring is so important to software because it is really all about the
patterns. You don't have to have a "traditional" OO language. Refactoring
works in Erlang!
Refactoring will make you a better Erlang developer. I can't prove it. But
I'll show you personally in our development environment the next time any of
you are in Chicago.
More information about the erlang-questions