Jump to content

Talk:Action at a distance (computer programming)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by RJFJR (talk | contribs) at 01:39, 30 September 2005 (paragraph removed from article). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Is the Perl code really necessary here? I understand from the discussion that it is a language that has historically suffered from many problems of this kind, but the code for "package WhineyScalar" is completely incomprehensible to me -- and I used to be a part-time Perl programmer for a while, only five years ago. Perhaps it would be best if it were placed on a web page and a link added in the "See also" section?

Also, what exactly is "MoveCollectionsOfFunctionsToObjects" and how does it help reduce action across objects? It sounds like a design pattern, but it's not one I've come across before, and isn't in my copy of the original Design Patterns book. A search for that text (with spaces added) on wikipedia turns up no matching documents either.

JulesH 9 July 2005 19:06 (UTC)


Catching action at a distance in scalars

I removed this material (icncluding the heading above) from the article to talk because it is perl specific.RJFJR 21:10, 29 September 2005 (UTC)[reply]

package WhineyScalar;

sub new { tie $_[1], $_[0]; }

sub TIESCALAR {
  bless \my $a, shift;
}

sub FETCH {
  my $me = shift;
  $$me;
}

sub STORE {
  my $me = shift;
  my $oldval = $$me;
  $$me = shift;
  (my $package, my $filename, my $line) = caller; 
  print STDERR "value changed from $oldval to $$me at ", join ' ', $package, $filename, $line, "\n";
}

1;

Use this with:

use WhineyScalar;
new WhineyScalar my $foo;
$foo = 30;  # this generates diagnostic output
print $foo, "\n";
$foo++;     # this generates diagnostic output

Using tie on a scalar, one can intercept attempts to store data, and generate diagnostics to help one track down what unexpected sequence of events is taking place.


removed from article

I removed this paragraph

Accumulate and fire situations should be replaced with a command object or whole object arrangement, or a model view controller configuration.

because it contains too many redlinks and isn't clear. If we are going to reinsert it then we need to reword it first (IMHO). RJFJR 01:39, 30 September 2005 (UTC)[reply]