[erlang-questions] Fear and Loathing in Programming La La Land

Vlad Dumitrescu vladdu55@REDACTED
Thu Mar 29 09:42:55 CEST 2012

Hi Richard,

On Thu, Mar 29, 2012 at 09:32, Richard O'Keefe <ok@REDACTED> wrote:
> Frankly, I've turned here for a bit of comfort.  If anyone likes completely
> initialising things rather than smacking one field at a time, surely I will
> find such people here.
> Am I wrong?  Would *you* be happy opening a file in C by doing
>        FILE *f = malloc(sizeof f);
>        set_title(f, "foo/bar.txt");
>        set_access(f, "r");
>        gets(f, buffer);

No, you are not wrong nor alone :-)

I'm doing a lot of Java these days and the "ideology" that I'm
following is to try to get *all* initialization in the constructor. If
there are many constructor parameters (especially with the same types,
when they are difficult to tell apart), then I use a builder object
that can construct my desired target one piece at a time and has
sensible defaults. Something like (made up example)
File f = new FileBuilder().withTitle("foo").withAccess("r").build();

best regards,

More information about the erlang-questions mailing list