[erlang-questions] Deriving records from one another?

Garrett Smith g@REDACTED
Mon Jun 23 16:58:52 CEST 2014

On Mon, Jun 23, 2014 at 9:47 AM, Roger Lipscombe <roger@REDACTED> wrote:
> On 23 June 2014 15:44, Roger Lipscombe <roger@REDACTED> wrote:
>> On 23 June 2014 15:08, Garrett Smith <g@REDACTED> wrote:
>>> How many fields are actually shared? Is it really a problem to just
>>> duplicate the values?
>> About 15. Granted, some of these go around together (ID has three
>> parts, for example), so could be in a smaller number of subrecords.
> I called for a recount: that's about 15 out of about 25, where those
> last 10 are basically only used between 'init' and 'ready'.

Are you pattern matching on all of these? That'd be a lot of logic for
a single module.

Of course there's nothing magical about "pattern matching" - but as
this usually surfaces at the function level, the behavior implemented
by your gen_server will reflect a lot of complexity across these 25

Is there logic/behavior that you can farm off to another module (or
more) in the interest of separating concerns? If yes, you can use
these modules to manage the state for a smaller number of top-level
fields. Your top level gen_server would handle the dispatch logic.

Someone mentioned using sub-processes to separate concerns. I'd
caution against that, unless in fact you have separate concurrent
activities (as in real life concurrent) that you want to represent. If
there's just one process here, use modules to manage opaque data
structures and implement behavior associated with that data (e.g. use
dict as a model for this type of module).

Again, probably clear as mud. Fire back if you need clarification.


More information about the erlang-questions mailing list