Kurt Stephens

Nerd Up!

Recent comments

Syndicate

Syndicate content

Browse archives

« January 2009  
Mo Tu We Th Fr Sa Su
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Kurt on Sun, 2006-10-22 22:26.

Data Transform Programming Style is somewhere between imperative and functional programming.

Data representations flow towards the desired result, from least expressive to most expressive. This allows greater reuse of code on multiple data representations, greater locality of intent and more literal coding. The nested nature of functional application is flattened into an imperative style that reads more like pseudo-code, while retaining functional elements.

Imagine a Perl program that takes a list of URIs and turns them into HTML <a href> tags:

# Imperative Example 1:

sub format_uri_as_html
{
  my ($uri) = @_;

  $uri = qq{<a href="$uri">$uri</a>};

  $uri;
}

my $uris = [
  'http://kurtstephens.com',
  'http://google.com',
  'http://digg.com',
];

print map(format_uri_as_html($_) . "\n", @$uris);

Simple imperative programming; we side-effect $uri till we have HTML and return it.

Now requirements change…


links: read more | add new comment | 1621 reads

Reply

The content of this field is kept private and will not be shown publicly.
Captcha Image: you will need to recognize the text in it.
Please type in the letters/numbers that are shown in the image above.