Erlang hints for an OO junkie
Mon Aug 9 17:32:27 CEST 2004
I just finished writing an article for the Snowbird ICFP workshop on
erlang entitled "Structured Programming Using Processes". Look for it
when the conference comes out or check my website in November.
The basic premise in the paper is to think of data flows and processes
rather than OO. In OO an object is stored and represented in a single
place with all the code that can access the data. In erlang, messages
are sent from process to process so data can be stored in whatever
format is best for each process. You may neeed to keep things in a
database, so you can have one table per object type, or coerce all to
fit in a single table with some extra columns. A process could read the
currently relevant ones in as a list and dole them out to other
processes for manipulation. User commands can be received, transformed
and routed to the process holding the object in question.
For your gaming problem you need to decide what must be done
concurrently and what must be done sequentially. Everything else can go
either way. If you have a process for each person or monster (animate
entities), internal to the process can be their possessions which they
can give to another process in exchange for something else. The same
can happen with traits.
If you are stuck on objects, make a process for every object. You will
run into some problems, but you may feel comfortable.
More information about the erlang-questions