[erlang-questions] Fear and Loathing in Programming La La Land
Thu Mar 29 10:04:22 CEST 2012
On 2012-03-29, at 09:32 , Richard O'Keefe wrote:
> 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);
I'm not aware of very many people who'd be: even back when I used Java,
most people I worked with were not fond of this style at all (and IOC
containers, which were gaining in popularity, tended to promote
constructor injection — where all values are set in the constructor
— more than property injection — where the constructor takes no
argument and all properties are set via setters).
Going through constructors/atomically building objects has issues mostly
in two situations: a language without keyword arguments — which can be
neatly side-stepped by using "builders"; and objects with far too much
configurable state — which should be solved by breaking things into
smaller and more self-contained pieces.
To answer the question, no, I can't say I would be happy.
More information about the erlang-questions