[erlang-questions] good form?

Lukas Larsson garazdawi@REDACTED
Thu Nov 25 14:49:55 CET 2010


Hi,

I've had precisely the same problem with webmachine and went with solution
number two. It does however present some problems as webmachine (last I
checked) uses the exports of the module to determine which responses to give
and you could end up replicating some of the functionality of webmachine
with in the base module.

Besides that it worked very well and I've used the same aproach in a lot of
places with great success. The library module aproach is probably easier to
understand and maintain by someone else, but in my opinion a base module is
the better solution.

Lukas

On Thu, Nov 25, 2010 at 1:25 AM, Andy Kriger <andy.kriger@REDACTED> wrote:

> I'm playing around with Webmachine and what I'm finding is that in my
> resources (the handlers for RESTful dispatch targets), there's
> duplicated functionality. Fine, no problem there - three approaches I
> can take:
> 1) a library module that those Webmachine functions can call out to
> 2) have my resource modules extend a base resource module that
> implements common functionality
> 3) setup a delegate module that those Webmachine functions can call
> out (one benefit of this over #1 is that a change to which
> implementation is needed is handled either in the delegate or by
> changing delegates, not in each resource calling a library module)
>
> Combinations of the approaches are possible too. I'm curious to hear
> from more experienced Erlangers on if extends is an accepted practice,
> if delegation is a common Erlang pattern (or just a pattern that I'm
> carrying over from OO/Java), if there's a pattern I'm missing here
> (I'm suspecting something with messaging is the real solution, but I
> honestly don't know enough Erlang to know if I'm barking up the wrong
> tree there).
>
> thx
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>


More information about the erlang-questions mailing list