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

Jan Burse <>
Thu Apr 5 01:50:42 CEST 2012


Garrett Smith schrieb:
> It's no surprise at all to me that developers in these communities
> prefer zero arg constructors and property configuration.
>
> These are just two totally, totally different world views. Almost
> certainly dangerous to cross the streams [2].
>
> Garrett

Either you are relatively young that you don't
know, or you haven't been around much.

Widgets with attributes are in existence before
Visual C and Java. For example we find <1988 the
Athena Widget set for X11 (*).

These Widget sets have a different kind of API.
For the programmer there are generic constructors
and generic setters, which make use of varargs.
These varargs are supposed to be lists of key
value pairs.

     createXXX(.., KEY1, VALUE1, ..., KEYn, VALUEn).

     set(.., KEY1, VALUE1, ..., KEYn, VALUEn).

Since widgets have a state and are supposed to be
muttable, it is perfectly valid to have setters
beside an initial constructor.

The setters can be used to change the features of
the widgets in the course of the interaction with
the end-user in the user interface. There existence
is not determined by some GUI builders.

I don't think we can make a case against setters.
But we can make a case against the research paper
that has spun this thread: varargs are a third option
in creating an API.

But I guess there are possibly even further options,
maybe already found in some widget sets for X11, that
come with their own programming paradigms.
Not sure. (**)

Bye

(*)
X Toolkit - Intrinsics & Athena Widgets
by McCormack, Asente, Swick, & Weissman
ISBN 0-929306-04-X, 1988
http://www.silicon-press.com/books/isbn.0-929306-04-X/index.html

(**)
Here is a furth approach, its not X11, its QNX.
Building an array, and passing it. The array holds
key, value-ptr, value-size tripples:
PtSetArg(&args[0], Pt_ARG_TEXT_STRING,
              "Press to exit", 0);
PtCreateWidget(PtButton, window, 1, args);
http://www.qnx.com/developers/docs/qnx_4.25_docs/photon114/prog_guide/nonphab.html



More information about the erlang-questions mailing list