Jump to content

Action at a distance (computer programming)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by TakuyaMurata (talk | contribs) at 05:06, 31 July 2004. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

In some subcultures of programming (see, e.g., http://perldesignpatterns.com/?ActionAtADistance), action at a distance refers to having a variable or condition in one part of a program structure which varies wildly based on difficult or impossible to identify operations in another part of the program.

One example is a data structure that unpredictably changes its format between when it is created and when it is used. In Perl, one way to observe this is by setting the variable $[, which determines the starting value of the numeric index of arrays, to something arbitrary, such as 20 or 4.

The most obvious way to avoid such a problem is to make changes in code at a local rather than a global level.

Action at a distance is an example of an anti-pattern.

One of the advantages of Functional programming is that action at a distance is de-emphasised, sometimes to the point of being impossible to express at all in the source languge.