is Ben Rudgers

Remarks: Epigram 11

This is part of a writing exercise around Alan Perlis‘s Epigrams in Programming.

If you have a procedure with 10 parameters, you probably missed some.

A plot device involving ten characters may invovle a Balrog; consider the side effects of Balrogs before incorporating such a plot device.

A procedure requiring ten parameters may be a sign that the procedure is highly dependent on program state . If highly dependent on state, it is likely that ten parameters do not capture the entirety of the relevant state. In cases where the parameters are not capturing state but values, then better data abstractions are called for – obviously the values are related, otherwise the procedure would not be using them together.

There are command line programs which have many optional parameters – but optional parameters would seem to be a different case – since what is optional cannot be missing in the sense the epigram implies.

Our intuition  is that these parameters are keyword associated – and tend to denote “helper” functions which either modify the interpretation of the input or format the output. Unlike the ten parameter procedure, the source for these options is the user’s mind, not the programmer’s – they are selected at run time, not compile time. The program has to ask the user what they want, there is no other way to read her mind.

Ten parameters for a programming construct is analogous to  our program is asking us for data. Instead it should read what is already there. It speaks to a mismatch between our data structures and our procedures. They are not mapping together well. Or it means that we are not controlling state but still depending on it.

The user space view and the programmer space view overlap in areas like SQL queries. These may be constructed from multiple arguments.  But like keyword arguments on the command line the elements are built up and optional.