[erlang-questions] Mock functions

Arnaud Bailly abailly@REDACTED
Mon Sep 4 17:45:35 CEST 2006


Just to be clear, is here is a decription of what I am trying to do.
I want to implement a simple billing web application to evaluate
erlang's potential as a tool for model driven engineering: I want to
generate  a functional skeleton of an application from a model. But
before I can do this, I need to learn erlang and usage of OTP platform
:-)

I have written my model (ie. defined records structure) and now
implementing business logic (ie. functions for computing values,
retrieving stored data, updating ...). I want my code to be unit
tested and I want to be somuwhat independent from the underlying
storage used: I could store data in ets tables or in mnesia databases,
depending on the usage context. 

So I am trying to define a generic Data accesse interface that can
query record constructs, update, delete or create them in a standard
way (BTW, there may already exists such things). In the Java world, I
would use some object-relational mapping or direct SQL queries encoded
into Data-access objects for insulating businees code from storage
impl. 

So the question is: In erlang, how can I provide "virtual" functions ?
I think the only way would be to "thread" a DB interface record
containing functions as field into all my business methods. In
Haskell, I could write a monad and encapsulate all my business logic
in a DB Monad for abstracting away side-effects on the DB layer. In
java, I create a reference to a DAO interface that is wired to
business object at deploy or creation time. 

What is the Erlang way to do this ?

Thx

-- 
OQube < software engineering \ génie logiciel >
Arnaud Bailly, Dr.
\web> http://www.oqube.com





More information about the erlang-questions mailing list