[erlang-questions] Using processes to implement business logic

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Sat Jan 31 16:23:05 CET 2015


On Fri, Jan 30, 2015 at 11:52 AM, Camille Troillard <lists@REDACTED> wrote:

> It looks like, in the context of our problem, we should have more
> advantages implementing our domain model using processes rather than simple
> Erlang records. It also appears that processes will act as a nice cache
> layer in front of the persistent storage.


In the words of the Subject/Object dichotomy[0]: do you want your business
entities to "act" or be "acted upon" ?

If the former is true, then make them into processes. This is often the
case if your entities are "alive" and needs to query databases, have
timeouts, needs to manage persistence and so on. Or if the processing of an
entity is complex with many different advanced code paths.

If the latter is true, then make them into records. This is usually good if
your data can be batch-processed and is just "dead" data, where other
systems are using that data to work. This often leads to a pipeline
processing chain where workers (subjects) operate on the entities. This is
also the only viable model in many programming languages.

[0] http://en.wikipedia.org/wiki/Subject%E2%80%93object_problem

-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150131/0ca58467/attachment.htm>


More information about the erlang-questions mailing list