<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Mastering the Tao of Personal Computing</title>
	<atom:link href="http://npacemo.com/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://npacemo.com/wordpress</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Sat, 27 Mar 2010 06:18:19 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Flex 3 Animated Scrolling (a.k.a. Smooth Scroll)</title>
		<link>http://npacemo.com/wordpress/2009/10/24/flex-3-animated-scrolling-aka-smooth-scroll/</link>
		<comments>http://npacemo.com/wordpress/2009/10/24/flex-3-animated-scrolling-aka-smooth-scroll/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 09:16:04 +0000</pubDate>
		<dc:creator>Vladimir Tsvetkov</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Animated]]></category>

		<category><![CDATA[Easing]]></category>

		<category><![CDATA[Flex 3]]></category>

		<category><![CDATA[ScrollBar]]></category>

		<category><![CDATA[Smooth]]></category>

		<category><![CDATA[Tween]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=69</guid>
		<description><![CDATA[Almost year and a half ago I&#8217;ve wrote an article about making a pretty custom scroll-bar with a Fixed Sized Scroll-Thumb - a task known in the community as a designer scroll-bar. Both blog posts proved to be useful, but just recently I received an email from this very cool guy Dino from Canada with [...]]]></description>
			<content:encoded><![CDATA[<p>Almost year and a half ago I&#8217;ve wrote an article about making a pretty custom scroll-bar with a <a href="http://npacemo.com/wordpress/2008/05/20/flex-3-designer-scrollbar-fixed-size-scrollthumb/">Fixed Sized Scroll-Thumb</a> - a task known in the community as a <a href="http://www.gskinner.com/blog/archives/2008/05/designer_scroll.html">designer scroll-bar.</a> Both blog posts proved to be useful, but just recently I received an email from this very cool guy Dino from Canada with the following question.</p>
<p><i><strong>Dino wrote:</strong></i><br />
<span style="border-style: solid; border-width: 1px; margin: 14px; padding: 5px 10px; display: block; background-color: oldLace; font-style: italic;">I was also wondering how would I go about adding easing to the scrolling of a VBox? I don’t think there is an out-of-box solution such as an Accordion having a style property openEasingFunction that allows you to specify easing but I could be wrong. Does this require customization of the Container class? I was looking at Container.scrollChildren() and other methods in the Container class to determine if I could override any behaviour.</span></p>
<p>Somehow his email coincided with a scroll-related task I had recently. I had to use a scroll-bar which is situated on a pretty custom position and it was strolling columns of content with a snapping effect. So, how would I approach the problem with the animated scroll-bar? </p>
<h3>The Solution</h3>
<p>Going for extending the Container or some of the others Flex containers is a hairy and let&#8217;s say adventurous direction to proceed with. And I believe the solution won&#8217;t be much flexible. What would you do if you need to place the scroll-bar on a more peculiar place (e.g. on the left or the top side of the container sizes or event somewhere else outside the scrolled container)?</p>
<p>The solution is to detach the scroll-bar from the container, so we can use an outside scroll-bar. The following code fragment shows you how to achieve this: </p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
&lt;!-- 1. Place the View that needs scrolling into a Canvas which represents the visible area
     which can't be exceeded by the View.
     !!!IMPORTANT!!! Disable the scrolling of the Canvas, so we can use a detached scroller,
     which we can place wherever we want (e.g. on the left or top sides of the Canvas) --&gt;
&lt;mx:Canvas id="viewContainer"
    width="{largerView.width}" height="500"
    verticalScrollPolicy="off" horizontalScrollPolicy="off"
    borderColor="black" borderStyle="solid"&gt;
    &lt;view:ViewThatNeedsScroll id="largerView"/&gt; &lt;!-- THIS IS THE VIEW --&gt;
&lt;/mx:Canvas&gt;

&lt;!-- 2. Create a Canvas with fictive content - this is the actual detatched scroll-bar.
     Make sure the dimensions of this Canvas are corresponding to the size of the visible
     area specified by the View-container. Also make sure the fictive content has dimensions
     corresponding to the the dimensions of the View.
     Use data binding to set the corresponding dimensions! --&gt;
&lt;mx:Canvas id="scrollerContainer"
    x="{viewContainer.x - scrollerContainer.width}"
    y="{viewContainer.y}"
    width="40" height="{viewContainer.height}"&gt;
    &lt;mx:Canvas width="1" height="{largerView.height}"/&gt; &lt;!-- THIS IS FAKE CONTENT --&gt;
&lt;/mx:Canvas&gt;
</pre>
<p/>
<h3>The Simplest Way to Attach the Scroll-Bar to the View</h3>
<p>Before trying to add a tween and an easing to the scrolling motion, I&#8217;ll show you the most simplest solution for attaching this outer scroll-bar to the View that needs to be scrolled:</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
&lt;!-- 3. Use Data Binding to attach the scroller to the View: --&gt;
&lt;mx:Binding source="scrollerContainer.verticalScrollPosition"
    destination="viewContainer.verticalScrollPosition"/&gt;
</pre>
<p/>
<p>Here&#8217;s the working sample (<strong>view source</strong> is enabled):</p>
<div style="margin: 20px 0 20px 0; width: 500px; height: 200px;">
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="DetachedScroller" width="500" height="200" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><param name="movie" value="http://npacemo.com/sample-applications/bin-detached-scroller/SmoothScroller.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><param name="allowScriptAccess" value="sameDomain" /><embed src="http://npacemo.com/sample-applications/bin-detached-scroller/SmoothScroller.swf" quality="high" bgcolor="#000000" width="500" height="200" name="DetachedScroller" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"></embed></object>
</div>
<h3>Animating the Scrolling</h3>
<p>I&#8217;ve implemented a simple controller component which animates the scrolling movement. You can adjust various properties of the <strong>ScrollerController</strong>, such as:</p>
<p style="margin-left: 20px;">
    ● interaction delay<br />
    ● easing function<br />
    ● max duration of the tween<br />
    ● etc.
</p>
<p>I&#8217;m not going to look at the controller&#8217;s implementation in details. Feel free to ask me any questions in the comments section.</p>
<p>Here&#8217;s the working sample (<strong>view source</strong> is enabled):</p>
<div style="margin: 20px 0 20px 0; width: 500px; height: 300px;">
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="DetachedScroller" width="500" height="200" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><param name="movie" value="http://npacemo.com/sample-applications/bin-animated-scroller/SmoothScroller.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><param name="allowScriptAccess" value="sameDomain" /><embed src="http://npacemo.com/sample-applications/bin-animated-scroller/SmoothScroller.swf" quality="high" bgcolor="#000000" width="500" height="300" name="DetachedScroller" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"></embed></object>
</div>
<p><strong>Tell me what do you think of my solution? How would you solve this problem?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2009/10/24/flex-3-animated-scrolling-aka-smooth-scroll/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flash Smoothing Issue</title>
		<link>http://npacemo.com/wordpress/2009/07/31/flash-smoothing-issue/</link>
		<comments>http://npacemo.com/wordpress/2009/07/31/flash-smoothing-issue/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 11:21:04 +0000</pubDate>
		<dc:creator>Vladimir Tsvetkov</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Bitmap]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[issue]]></category>

		<category><![CDATA[smoothing]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=68</guid>
		<description><![CDATA[Smoothing in Flash won&#8217;t work with every image. This is a bit of an old discovery, but yesterday I ran again into this issue and I had the luck to recall what was the reason for it, and decided to document it in my blog in case I run again into this issue. 
Almost two [...]]]></description>
			<content:encoded><![CDATA[<p>Smoothing in Flash won&#8217;t work with every image. This is a bit of an old discovery, but yesterday I ran again into this issue and I had the luck to recall what was the reason for it, and decided to document it in my blog in case I run again into this issue. </p>
<p>Almost two years ago my colleague Barni and I literally spent half a day in finding what causes this behavior. We&#8217;ve tried everything - drawing the loaded bitmap into a new <strong>BitmapData</strong>-object with the <strong>smoothing</strong> argument set to <strong>true</strong>, but with no luck. And then it suddenly struck us - it was the image dimensions. Images that have an odd dimension(s) fail to be smoothed. Check the sample app beneath - choose a different image from the combo and observe whether the smoothing works for it:</p>
<div style="margin: 20px 0 20px 0; width: 500px; height: 350px;">
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="SmoothingIssue" width="500" height="350" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><param name="movie" value="http://npacemo.com/sample-applications/bin-release-smoothing-not-fixed/SmoothingIssue.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><param name="allowScriptAccess" value="sameDomain" /><embed src="http://npacemo.com/sample-applications/bin-release-smoothing-not-fixed/SmoothingIssue.swf" quality="high" bgcolor="#000000" width="500" height="350" name="SmoothingIsssue" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"></embed></object>
</div>
<h3>The Solution</h3>
<p>The solution is to create a new BitmapData-object that is always with even dimensions.</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
var smoothBitmapData : BitmapData = new BitmapData(
    loadedBitmap.width + (loadedBitmap.width % 2),
    loadedBitmap.height + (loadedBitmap.height % 2),
    true, 0x00FF0000);
smoothBitmapData.draw(
    loadedBitmap, null, null, null, null, true);

smoothBitmap = new Bitmap(
    smoothBitmapData, PixelSnapping.NEVER, true);
</pre>
<p/>
This is how it looks with the fix:</p>
<div style="margin: 20px 0 20px 0; width: 500px; height: 350px;">
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="SmoothingIssue" width="500" height="350" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><param name="movie" value="http://npacemo.com/sample-applications/bin-release-smoothing-fixed/SmoothingIssue.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><param name="allowScriptAccess" value="sameDomain" /><embed src="http://npacemo.com/sample-applications/bin-release-smoothing-fixed/SmoothingIssue.swf" quality="high" bgcolor="#000000" width="500" height="350" name="SmoothingIsssue" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"></embed></object>
</div>
<p><a href="http://npacemo.com/sample-applications/bin-release-smoothing-fixed/srcview/index.html">VIEW SOURCE</a></p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2009/07/31/flash-smoothing-issue/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Do the Evolution!</title>
		<link>http://npacemo.com/wordpress/2009/07/15/do-the-evolution/</link>
		<comments>http://npacemo.com/wordpress/2009/07/15/do-the-evolution/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 14:58:30 +0000</pubDate>
		<dc:creator>Vladimir Tsvetkov</dc:creator>
		
		<category><![CDATA[Personal Computing]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[cryptography]]></category>

		<category><![CDATA[evolution]]></category>

		<category><![CDATA[genetic algorithm]]></category>

		<category><![CDATA[perl]]></category>

		<category><![CDATA[simple substitution]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=67</guid>
		<description><![CDATA[DOWNLOAD THE CODE (WRITTEN IN PERL)
Well, that&#8217;s an oldie! During the Cryptography course in the university (4 years and a half ago) I had an assignment to decipher a simple substitution cipher. Deciphering such ciphers is really straight-forward, but the extravagant part of me decided, that I&#8217;m too special to go with the straight way, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://openfmi.net/snippet/detail.php?type=snippet&#038;id=25">DOWNLOAD THE CODE (WRITTEN IN PERL)</a></p>
<p>Well, that&#8217;s an oldie! During the Cryptography course in the university (4 years and a half ago) I had an assignment to decipher a simple substitution cipher. Deciphering such ciphers is really straight-forward, but the extravagant part of me decided, that I&#8217;m too special to go with the straight way, so I&#8217;ve decided to try an alternative approach. Inspired from the Soft Computing course I attended the previous term, I was determined to experiment with a genetic algorithm and to play God with the small world of 20 populations with 20 individuals each possessing a unique DNA.</p>
<h3>My Conclusion</h3>
<p><strong>Well, does the evolution work or what?</strong> No matter how many times I&#8217;ve ran the evolution, it ended producing individuals which doesn&#8217;t look much like English - I had no luck with an exact match. Nevertheless the individuals bred by the process helped me a lot to recognize the English sentence that was in the cipher.</p>
<h3>The Source Code</h3>
<p>My implementation is in Perl - this language seemed most suitable for the task.</p>
<p>This is a slightly modified implementation of the genetics algorithm, described in <a href="http://www.cs.rochester.edu/u/brown/Crypto/studprojs/SubstGen.pdf">&#8220;Solving Substitution Ciphers with Genetics Algorithm&#8221; by Joe Gester</a>. A corpus of English text should be supplied - in this sample I pasted in the <i>corpus.txt</i> file <a href="http://eserver.org/fiction/innocence/secretgarden.html">&#8220;The Secret Garden&#8221; by G.K. Chesterton</a>.</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
#########################################################################
# Solving Substitution Ciphers with Genetics Algorithm!			#
# 	(c) Vladimir Tsvetkov, 2005					#
# 	For selfsatisfaction only!					#
#########################################################################

#!/usr/bin/perl

use warnings;
use strict;

###############################################################################
# cypher text that is about to be cracked:
my $cypher_text = "BTKIB" . "OKIBR" . "BAARJ" . "ZGBON" . "QBBSH" . "OZIBM"
		. "BAAGB" . "ONZAH" . "RANMH" . "OZIBI" . "JQSAB" . "WKNHM"
		. "KTLBJ" . "ZZIBR" . "BWKQH" . "RWKHA" . "HHPJU" . "HVKIB"
		. "OJWQK" . "HRHWQ" . "BORIJ" . "KRJZX" . "HTWXK" . "HIJSS"
		. "BWWBC" . "K";

###############################################################################
# almost randomly chosen corpus in English:
# use this to calculate the digram and trigram frequency tables:
my $corpus = "";

###############################################################################
# capitalize all letters in the corpus, remove spaces, numbers and punctuation:
sub prepare_corpus {
	open (CORPUSFILE, '<', "corpus.txt")
		or die "Can't open file! $!";
	my @contents = <CORPUSFILE>;
	close (CORPUSFILE);
	foreach my $paragraph (@contents) {
		$corpus .= $paragraph;
	}
	$corpus =~ tr/a-z/A-Z/;	# capitalize
	$corpus =~ s/\s//g;	# remove spaces
	$corpus =~ s/\W//g;	# remove punctuation and other symbols
	$corpus =~ s/\d//g;	# remove digits
}

prepare_corpus ();

###############################################################################
# alphabeth we use:
my $alphabeth = &#8220;ABCDEFGHIJKLMNOPQRSTUVWXYZ&#8221;;

###############################################################################
# letters distribution for the alphabeth we use (in %):
# if you are using another alphabet, you should change this table!
my %letter_distribution_table = (
	&#8216;E&#8217; => 12.31,	 &#8216;L&#8217; => 4.03, 	&#8216;B&#8217; => 1.62,
	&#8216;T&#8217; => 9.59,	 &#8216;D&#8217; => 3.65, 	&#8216;G&#8217; => 1.61,
	&#8216;A&#8217; => 8.05,	 &#8216;C&#8217; => 3.20, 	&#8216;V&#8217; => 0.93,
	&#8216;O&#8217; => 7.94,	 &#8216;U&#8217; => 3.10, 	&#8216;K&#8217; => 0.52,
	&#8216;N&#8217; => 7.19,	 &#8216;P&#8217; => 2.29, 	&#8216;Q&#8217; => 0.20,
	&#8216;I&#8217; => 7.18,	 &#8216;F&#8217; => 2.28, 	&#8216;X&#8217; => 0.20,
	&#8216;S&#8217; => 6.59,	 &#8216;M&#8217; => 2.25, 	&#8216;J&#8217; => 0.10,
	&#8216;R&#8217; => 6.03,	 &#8216;W&#8217; => 2.03, 	&#8216;Z&#8217; => 0.09,
	&#8216;H&#8217; => 5.14,	 &#8216;Y&#8217; => 1.88
);

###############################################################################
# digram frequency table:
my %digram_frequency_table = ();

# this will populate the %digram_frequency_table:
sub calculate_digram_frequency_table {
	my $i = 1;
	foreach my $letter (split (//, $corpus)) {
		last if ($i == length $corpus);
		my $digram = $letter . substr ($corpus, $i, 1);
		$i ++;
		if (defined $digram_frequency_table{$digram}) {
			$digram_frequency_table{$digram} ++;
		} else {
			$digram_frequency_table{$digram} = 1;
		}
	}
}

calculate_digram_frequency_table ();

###############################################################################
# trigram frequency table:
my %trigram_frequency_table = ();

# this will populate the %trigram_frequency_table:
sub calculate_trigram_frequency_table {
	my $i = 1;
	foreach my $letter (split (//, $corpus)) {
		last if ($i == (length $corpus) - 1);
		my $trigram = $letter . substr ($corpus, $i, 2);
		$i ++;
		if (defined $trigram_frequency_table{$trigram}) {
			$trigram_frequency_table{$trigram} ++;
		} else {
			$trigram_frequency_table{$trigram} = 1;
		}
	}
}

calculate_trigram_frequency_table ();

###############################################################################
# implementing the crossover between individuals:
# as long as less than half of the key is swapped at any one time, at least
# the good information from one parent remains in the child and likely the
# majority of the good information from the other parent also remains
# Example:
# father - A (B  C  D) E  F
# mother - B  D  F  E  C  A
# the crossover takes the next 3 steps:
# 1. tr/BD/DB/
# 2. tr/CF/FC/
# 3. tr/DE/ED/
# child  - E  B  C  D  F  A
sub crossover {
	my ($father, $mother) = @_;
	my $letters_count = length $alphabeth;
	my $crossover_fragment_length = 12;
	my $fragment_offset =
		int (rand ($letters_count - $crossover_fragment_length + 1));

	my $child = $mother;
	my $father_fragment = substr ($father,
				$fragment_offset,
				$crossover_fragment_length);

	my $mother_fragment = substr ($mother,
				$fragment_offset,
				$crossover_fragment_length);

	# swap the randomly chosen fragments:
	my $i = 0;
	foreach my $father_letter (split (//, $father_fragment)) {
		my $mother_letter = substr ($mother_fragment, $i, 1);
		$i ++;
		my $digram_left = $father_letter . $mother_letter;
		my $digram_right = $mother_letter . $father_letter;
		$_ = $child;
		eval &#8220;tr/$digram_left/$digram_right/&#8221;;
		$child = $_;
	}

	return $child;
}

###############################################################################
# implementing the fitness function for a given individual:
# To apply the fitness function to an individual, the cipher-text is decrypted
# using the individual’s gene as it’s key. Then every trigram and digram in
# the decrypted text is looked up in the table of how many times it occurs
# in the corpus. These numbers are then summed. Thus, trigrams and bigrams
# that occur commonly in the corpus are more heavily rewarded than those
# that do not.
sub fitness {
	my ($individual) = @_;
	my $permutated_alphabeth = $individual;
	my $plain_text = $cypher_text;

	# decrypt, using the given individual:
	$_ = $plain_text;
	eval &#8220;tr/$permutated_alphabeth/$alphabeth/&#8221;;
	$plain_text = $_;

	# calculate the fitness function of the decrypted text:
	my $fitness = 0;
	my $i = 1;
	foreach my $letter (split (//, $plain_text)) {
		unless ($i == length $plain_text) {
			my $next_letter = substr ($plain_text, $i, 1);
			my $digram = $letter . $next_letter;
			$fitness += $digram_frequency_table{$digram}
				if (defined $digram_frequency_table{$digram});
			unless ($i == (length $corpus) - 1) {
				my $next_two_letters = substr ($plain_text, $i, 2);
				my $trigram = $letter . $next_two_letters;
				$fitness += $trigram_frequency_table{$trigram}
					if (defined $trigram_frequency_table{$trigram});
			} else {
				$i ++;
				next;
			}
		} else {
			last;
		}
		$i ++;
	}

	return $fitness;
}

###############################################################################
# implementing mutation:
# This is implemented as a swap between probable neighbors based on the
# single letter frequencies of English. That is, the character ’e’ might
# be swapped with ’t’ but not with ’v’ or ’x’.
# In this case the random swap occurs only for the first 9 most frequent
# letters, based on the %letter_distribution_table.
sub mutation {
	my ($individual) = @_;
	my $mutated_individual = $individual;
	my $letters_count = 9;
	my $letter_position1 = int (rand ($letters_count));
	my $letter_position2 = int (rand ($letters_count));
	return $mutated_individual if ($letter_position1 == $letter_position2);
	my @letters_sorted_by_distribution =
		reverse
			sort  { $letter_distribution_table{$a} <=>
				$letter_distribution_table{$b} }
				keys %letter_distribution_table;
	my $letter1 = $letters_sorted_by_distribution[$letter_position1];
	my $letter2 = $letters_sorted_by_distribution[$letter_position2];
	my $index1 = index ($alphabeth, $letter1);
	my $index2 = index ($alphabeth, $letter2);
	my @letters = split (//, $individual);
	my $swap_letter1 = $letters[$index1];
	my $swap_letter2 = $letters[$index2];
	my $digram_left = $swap_letter1 . $swap_letter2;
	my $digram_right = $swap_letter2 . $swap_letter1;
	$_ = $mutated_individual;
	eval &#8220;tr/$digram_left/$digram_right/&#8221;;
	$mutated_individual = $_;
	return $mutated_individual;
}

###############################################################################
# generate random individual (generates random permutation of the alphabeth):
sub generate_random_individual {
	my @letters = split (//, $alphabeth);
	my $random_individual = &#8221;;
	foreach my $i (reverse (1 .. length $alphabeth)) {
		my $pos = int (rand $i);
		$random_individual .= $letters[$pos];
		# delete the concatenated element from @letters:
		unless ($pos == $#letters) {
			my $temp = $letters[$#letters];
			$letters[$#letters] = $letters[$pos];
			$letters[$pos] = $temp;
			pop @letters;
		} else {
			pop @letters;
		}
	}
	return $random_individual;
}

###############################################################################
# number of populations:
my $populations_count = 20;

###############################################################################
# number of individuals in a population:
my $individuals_count = 20;

###############################################################################
# array of populations:
my @populations;

###############################################################################
# describe a population of indiliduals:
# my $population = {
#	&#8216;individuals&#8217; => [],
#	&#8216;total_fitness&#8217; => 0
# };

###############################################################################
# describe an individual:
# my $individual = {
#	&#8216;description&#8217; => &#8221;,
#	&#8216;fitness&#8217; => 0
# };

###############################################################################
# sort individuals in a population by the fitness function:
sub sort_individuals {
	my ($population) = @_;
	@{$population->{&#8217;individuals&#8217;}} =
		reverse sort { $a->{&#8217;fitness&#8217;} <=> $b->{&#8217;fitness&#8217;} }
			@{$population->{&#8217;individuals&#8217;}};
}

###############################################################################
# sort populations by the cumulative fitness values:
sub sort_populations {
	@populations =
		reverse sort { $a->{&#8217;total_fitness&#8217;} <=> $b->{&#8217;total_fitness&#8217;} }
			@populations;
}

###############################################################################
# initialize the first generation:
sub zero_generation {
	foreach (1 .. $populations_count) {
		my $population = {};
		$population->{&#8217;individuals&#8217;} = [];
		$population->{&#8217;total_fitness&#8217;} = 0;
		foreach (1 .. $individuals_count) {
			my $individual = {};
			$individual->{&#8217;description&#8217;} = &#8221;;
			$individual->{&#8217;fitness&#8217;} = 0;
			my $random_individual = generate_random_individual ();
			$individual->{&#8217;description&#8217;} = $random_individual;
			my $fitness = fitness ($random_individual);
			$individual->{&#8217;fitness&#8217;} = $fitness;
			push (@{$population->{&#8217;individuals&#8217;}}, $individual);
			$population->{&#8217;total_fitness&#8217;} += $fitness;
		}
		sort_individuals ($population);
		push (@populations, $population);
	}
	sort_populations ();
}

###############################################################################
# number of individuals in a population that will mutate:
my $mutate_individuals_count = 4;

###############################################################################
# mutate some randomly chosen individuals in a population:
# A random range of $mutate_individuals_count individuals from a single
# population will mutate.
sub mutate_population {
	my ($population) = @_;
	my $offset = int
		(rand ($individuals_count - $mutate_individuals_count));
	foreach my $i (1 .. $mutate_individuals_count) {
		my $individual =
			${$population->{&#8217;individuals&#8217;}}[$offset + $i];
		my $mutated_description =
			mutation ($individual->{&#8217;description&#8217;});
		$individual->{&#8217;description&#8217;} = $mutated_description;
		$population->{&#8217;total_fitness&#8217;} -= $individual->{&#8217;fitness&#8217;};
		$individual->{&#8217;fitness&#8217;} =
			fitness ($mutated_description);
		$population->{&#8217;total_fitness&#8217;} += $individual->{&#8217;fitness&#8217;};
	}
	sort_individuals ($population);
}

###############################################################################
# mutate all populations:
sub mutate_all_populations {
	foreach my $population (@populations) {
		mutate_population ($population);
	}
	sort_populations ();
}

###############################################################################
# breed the individuals in a population:
# The father is chosen among the 5 best individuals in a population.
# The mother is chosen among the rest individuals in the same population.
# Their child takes the place of the weakest individual in the population.
sub breeding {
	my ($population) = @_;
	my $father_pos = int (rand (5));
	my $father_individual = ${$population->{&#8217;individuals&#8217;}}[$father_pos];
	my $mother_pos = int (rand ($individuals_count - 5)) + 5;
	my $mother_individual = ${$population->{&#8217;individuals&#8217;}}[$mother_pos];
	my $child_individual =
		${$population->{&#8217;individuals&#8217;}}[$individuals_count - 1];
	my $father = $father_individual->{&#8217;description&#8217;};
	my $mother = $mother_individual->{&#8217;description&#8217;};
	my $child = crossover ($father, $mother);
	$child_individual->{&#8217;description&#8217;} = $child;
	$population->{&#8217;total_fitness&#8217;} -= $child_individual->{&#8217;fitness&#8217;};
	$child_individual->{&#8217;fitness&#8217;} = fitness ($child);
	$population->{&#8217;total_fitness&#8217;} += $child_individual->{&#8217;fitness&#8217;};
	sort_individuals ($population);
}

###############################################################################
# breed all populations:
sub breed_all_populations {
	foreach my $population (@populations) {
		breeding ($population);
	}
	sort_populations ();
}

###############################################################################
# interbreeding between neighbour populations:
# The father is the best individual in the first population.
# The mother is randomly chosen individual from the next weakest population.
# Their child takes the place of the weakest individual in the mother&#8217;s
# population. I thought it&#8217;s quite reasonable to interbreed only neighbour
# populations (populations that have close values for the total_fitness).
sub interbreeding {
	foreach my $i (0 .. $populations_count - 2) {
		my $father_population = $populations[$i];
		my $father_individual =
			${$father_population->{&#8217;individuals&#8217;}}[0];
		my $mother_population = $populations[$i + 1];
		my $mother_pos = int (rand ($individuals_count));
		my $mother_individual =
			${$father_population->{&#8217;individuals&#8217;}}[$mother_pos];
		my $child_individual =
			${$mother_population->{&#8217;individuals&#8217;}}[$individuals_count - 1];
		my $father = $father_individual->{&#8217;description&#8217;};
		my $mother = $mother_individual->{&#8217;description&#8217;};
		my $child = crossover ($father, $mother);
		$child_individual->{&#8217;description&#8217;} = $child;
		$mother_population->{&#8217;total_fitness&#8217;} -=
			$child_individual->{&#8217;fitness&#8217;};
		$child_individual->{&#8217;fitness&#8217;} = fitness ($child);
		$mother_population->{&#8217;total_fitness&#8217;} +=
			$child_individual->{&#8217;fitness&#8217;};
		sort_individuals ($mother_population);
	}
	sort_populations ();
}

###############################################################################
# clone an individual:
sub clone_individual {
	my ($individual) = @_;
	my $cloned_individual = {};
	$cloned_individual->{&#8217;description&#8217;} = $individual->{&#8217;description&#8217;};
	$cloned_individual->{&#8217;fitness&#8217;} = $individual->{&#8217;fitness&#8217;};
	return $cloned_individual;
}

###############################################################################
# sort array of individuals:
sub sort_best_individuals {
	my ($ref_individuals) = @_;
	@$ref_individuals =
		reverse sort { $a->{&#8217;fitness&#8217;} <=> $b->{&#8217;fitness&#8217;} }
			@$ref_individuals;
}

###############################################################################
# the best individuals throughout all generations:
my @best_individuals;

###############################################################################
# check if this individual is not already in the @best_individuals array:
sub is_member_individual {
	my ($ref_individuals, $individual) = @_;
	foreach my $member_individual (@$ref_individuals) {
		if ($member_individual->{&#8217;description&#8217;} eq
		    $individual->{&#8217;description&#8217;}) {
			return &#8220;TRUE&#8221;;
		}
	}
	return undef;
}

###############################################################################
# merges to sorted lists of individuals:
sub merge_individuals {
	my ($ref_candidate_individuals) = @_;
	my @new_individuals = (@best_individuals);
	foreach my $candidate_individual (@$ref_candidate_individuals) {
		push (@new_individuals, $candidate_individual)
			unless (is_member_individual (\@new_individuals, $candidate_individual));
	}
	sort_best_individuals (\@new_individuals);
	$#new_individuals = $populations_count - 1;
	@best_individuals = @new_individuals;
}

###############################################################################
# select the best individuals, and if they are better than the existing ones,
# change them:
# This is a way to save the local maxima for all generations in the evolution.
sub select_best_individuals {
	if (@best_individuals) {
		my @best_individuals_in_this_generation;
		foreach my $population (@populations) {
			my $individual =
				clone_individual (${$population->{&#8217;individuals&#8217;}}[0]);
			push (@best_individuals_in_this_generation, $individual);
		}
		sort_best_individuals (\@best_individuals_in_this_generation);
		merge_individuals (\@best_individuals_in_this_generation);
	} else {
		# first initialization of @best_individuals;
		foreach my $population (@populations) {
			my $individual =
				clone_individual (${$population->{&#8217;individuals&#8217;}}[0]);
			push (@best_individuals, $individual);
		}
		sort_best_individuals (\@best_individuals);
	}
}

###############################################################################
# calculate cumulative fitness for all populations in a generation:
sub cumulative_fitness {
	my $cumulative_fitness = 0;
	foreach my $population (@populations) {
		$cumulative_fitness += $population->{&#8217;total_fitness&#8217;};
	}
	return $cumulative_fitness;
}

###############################################################################
# calculate next generation:
sub next_generation {
	breed_all_populations ();
	select_best_individuals ();
	interbreeding ();
	select_best_individuals ();
	mutate_all_populations ();
	select_best_individuals ();
}

###############################################################################
# decrypt the cypher text, using the individual&#8217;s description:
sub decrypt_individual {
	my ($individual) = @_;
	my $permutated_alphabeth = $individual->{&#8217;description&#8217;};
	my $plain_text = $cypher_text;
	# decrypt, using the given individual:
	$_ = $plain_text;
	eval &#8220;tr/$permutated_alphabeth/$alphabeth/&#8221;;
	$plain_text = $_;
	return $plain_text;
}

###############################################################################
# prints all suggestions about the decription of the cypher text:
sub print_results {
	open (RESULTS, &#8216;>&#8217;, &#8220;decriptions.txt&#8221;)
		or die &#8220;Can&#8217;t open file! $!&#8221;;
	foreach my $population (@populations) {
		foreach my $individual (@{$population->{&#8217;individuals&#8217;}}) {
			my $plain_text = decrypt_individual ($individual);
			print RESULTS &#8220;$plain_text\n&#8221;;
		}
	}
	print RESULTS &#8220;\nBEST SUGGESTIONS:\n&#8221;;
	foreach my $individual (@best_individuals) {
		my $plain_text = decrypt_individual ($individual);
		print RESULTS &#8220;$plain_text\n&#8221;;
	}
	close (RESULTS);
}

###############################################################################
# number of generations that are allowed to be without an improvement:
# on every improvement increment this value!
# on every worsening decrement this value!
my $generations_without_improvement = 10;

###############################################################################
# simulation of the evolution process:
sub evolution {
	my $cumulative_fitness = 0;
	zero_generation ();
	select_best_individuals ();
	$cumulative_fitness = cumulative_fitness ();
	my $generations = 0;
	while ($generations_without_improvement) {
		print &#8220;GENERATION $generations\t\tFITNESS: $cumulative_fitness\tGENERATIONS LEFT: $generations_without_improvement\n&#8221;;
		$generations ++;
		next_generation ();
		my $new_cumulative_fitness = cumulative_fitness ();
		if ($new_cumulative_fitness > $cumulative_fitness) {
			$generations_without_improvement ++;
			$cumulative_fitness = $new_cumulative_fitness;
		} else {
			$generations_without_improvement &#8211;;
		}
	}
	print_results ();
}

evolution ();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2009/07/15/do-the-evolution/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Formality vs. Informality</title>
		<link>http://npacemo.com/wordpress/2009/07/09/formality-vs-informality/</link>
		<comments>http://npacemo.com/wordpress/2009/07/09/formality-vs-informality/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 19:33:29 +0000</pubDate>
		<dc:creator>Vladimir Tsvetkov</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[informality]]></category>

		<category><![CDATA[ontology]]></category>

		<category><![CDATA[paper]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=66</guid>
		<description><![CDATA[I&#8217;m writing this blog post for the very same purpose I&#8217;ve decidedly written my latest university paper in English. I just want to reach the biggest possible audience in attempt to introduce you an idea that has the potential to change drastically the way we write software.
HERE YOU CAN DOWNLOAD MY PAPER
Prolog
Just as always when [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing this blog post for the very same purpose I&#8217;ve decidedly written my latest university paper in English. I just want to reach the biggest possible audience in attempt to introduce you an idea that has the potential to change drastically the way we write software.</p>
<p><a href="http://npacemo.com/papers/Ontologies_and_Ontology_Languages_for_Web-Service_Description.pdf">HERE YOU CAN DOWNLOAD MY PAPER</a></p>
<h3>Prolog</h3>
<p>Just as always when I have to write a paper for the university, I take the assigned topic and turn it into something completely different. And that&#8217;s exactly what I did for my Middleware paper. </p>
<p>My assignment was to write about <strong>Ontologies and Ontology Languages for Web Service Description</strong>, but it ended being a paper about <em>reassessing the role which formality plays in the field of software engineering</em>. </p>
<h3>So, how did I got from there to here?</h3>
<p>At the start, my intention was to take a couple of ontologies for web service description and to make an attempt to evaluate them according to a set of design criteria, as described in one of the most widely cited works in ontology - <a href="http://tomgruber.org/writing/onto-design.pdf ">Thomas R. Gruber, Toward Principles for the Design of Ontologies Used for Knowledge Sharing.</a></p>
<p>But guess what? It doesn&#8217;t work that way. And it won&#8217;t work that way, especially when you don&#8217;t have enough time. And what do I mean by that? </p>
<h3>The Impenetrable Citadel of Concentric Formality</h3>
<p>As soon as I started my acquaintance with one of the ontologies I&#8217;ve picked, I realized that I don&#8217;t know enough and that I need to get familiar with the underlying layer. When I started to get to know the thing underneath, same sh*t happened. I just couldn&#8217;t move on without picking into the layer beneath. Getting two floors down and I couldn&#8217;t remember anymore what was two floors above. </p>
<p>I&#8217;ve always considered layering a good thing, but what was happening then? Why I&#8217;m not able to learn about a system one layer at a time, without having to pick into the layers beneath? And it just struck me:</p>
<blockquote><p>All these layers of effective formality all the way down are simply inefficient&#8230;
</p></blockquote>
<p>&#8230;And it is inefficient not because it isn&#8217;t precise, but because it is maybe <strong>too precise</strong>. </p>
<h3>Why growing an interest in Lisp may matter?</h3>
<p>When you grew an interest about something, interesting things will start to happen to you. Things like discovering new stuff, discovering new ideas and most importantly discovering new amazing people. Scheme is probably the most amazing programming language I&#8217;ve learned in the university, but I haven&#8217;t been manifesting any forms of interest in Lisp until recently. And that&#8217;s how I discovered the work of <a href="http://www.cs.ubc.ca/~gregor/">Gregor Kiczales</a> - the creator of the Meta-Object Protocol for Lisp, the father of CLOS and the mind behind the Aspect-Oriented Programming. And one of the first things I did was listening to his keynote talk at OOPSLA 2007 (available as <a href="http://www.oopsla.org/podcasts/Keynote_GregorKiczales.mp3">podcast</a> and <a href="http://www.cs.ubc.ca/~gregor/papers/kiczales-oopsla-07-for-viewing.pdf">PDF slides</a>). Since then I&#8217;ve been listening to this same talk at least three more times. This talk is all about <strong>formality vs. informality</strong> and it ended being a road-map for my Middleware paper. A substantial part of the audio you can find almost as a transcript in my paper. I&#8217;ve been shamelessly repeating Kiczales&#8217; words with the hope they will raise some interest in these radical ideas.</p>
<h3>Disclaimer</h3>
<p>In advance, I want to apologize to all the experts that are familiar in much more detail with the stuff I wrote about in my paper. To them it may seem that I&#8217;m just scratching the surface, and probably they&#8217;re right. Forgive me, if I haven&#8217;t presented your ideas in the right way, or if I&#8217;ve misunderstood you. If that&#8217;s the case, it would be great if I hear back from you.</p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2009/07/09/formality-vs-informality/feed/</wfw:commentRss>
<enclosure url="http://www.oopsla.org/podcasts/Keynote_GregorKiczales.mp3" length="35846296" type="audio/mpeg" />
		</item>
		<item>
		<title>FLit - a Light-Weight Flex for Flash apps</title>
		<link>http://npacemo.com/wordpress/2009/06/30/flit-a-light-weight-flex-for-flash-apps/</link>
		<comments>http://npacemo.com/wordpress/2009/06/30/flit-a-light-weight-flex-for-flash-apps/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 14:45:05 +0000</pubDate>
		<dc:creator>Vladimir Tsvetkov</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[flex]]></category>

		<category><![CDATA[FLit]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=65</guid>
		<description><![CDATA[A whole class of RIA applications is getting judiciously ignored by technology vendors like Adobe and Microsoft with the argument that these are way too custom to be utilized in any direction. In the recent years both vendors were focusing their efforts on streamlining the enterprise RIAs, both neglecting the class of applications that was [...]]]></description>
			<content:encoded><![CDATA[<p>A whole class of RIA applications is getting judiciously ignored by technology vendors like Adobe and Microsoft with the argument that these are <strong>way too custom</strong> to be utilized in any direction. In the recent years both vendors were focusing their efforts on streamlining the enterprise RIAs, both neglecting the class of applications that was previously the predominant type of RIA. I&#8217;m talking about marketing platform applications or <em>Rich User Experiences that are not focused on providing a particular business function</em>. Such applications most typically are not extensively using common UI controls and usually they don&#8217;t have to deal with visualizing and manipulating large sets of data in grids and charts. </p>
<p>Adobe have done a great job with Flex (and in the years to come it will hopefully improve)! But Flex comes with a certain weight that makes it nearly impossible to use when we have to develop the class of applications that I want to stress on. The overhead of the framework is too big to be ignored. Our main concern is that this will eventually result in poorer user experiences, because of initial download times. But even if we circumvent this issue in some way (check my article on <a href="http://npacemo.com/wordpress/2008/07/06/flex-application-bootstrapping-totally-custom-preloader/">Totally Custom Preloaders</a>), the SWF will still include code dependencies that are used nowhere in the application. Not to mention that the whole component model is too heavy and complicated and will eventually stand in our way when we have to implement a totally custom experience.</p>
<h3>Introducing FLit</h3>
<p>But on the other hand Flex comes with a set of tools and concept that we really love and still want to be able to use. So what we end up doing in our free time in <a href="http://obecto.com/">Obecto</a> is a framework that would enable us to use Flex for really custom Flash apps with a minimal overhead from the framework. And we called this framework <a href="http://flit.googlecode.com/">FLit - a light-weight Flex for Flash apps</a>. We&#8217;ve developing it open source from line 1 - so feel free to check out the source from <a href="http://flit.googlecode.com/">Google Code</a>. There you&#8217;ll find some samples too!<br />
<img style="margin: 0 0 0 0;" title="flit-logo" src="http://npacemo.com/wordpress/wp-content/uploads/2009/06/flit-logo.png" alt="Introducing FLit!" width="500" height="215" /></p>
<h3>Why we call it FLit?</h3>
<p>First, FL stands for Flash. We want to build plain AS3 projects without the need to use <strong>&lt;mx:Application&gt;</strong> as a root object for our apps, and we want it to be as fast and as small as a plain AS3 project could be.</p>
<p><img style="margin: 0 0 0 0;" title="flit-and-flash" src="http://npacemo.com/wordpress/wp-content/uploads/2009/06/flit-and-flash.png" alt="FLit is Flash" width="500" height="281" /></p>
<h3>How do we use Flex in FLit?</h3>
<p>As you might guess FL also stands for Flex, but we only use a small subset of the Flex Framework, like Data Binding and MXML, and nothing else - no UIComponent, no Flex Application. How do we succeed in using MXML inside of a plain AS3 project? Well, this is a topic for another post.</p>
<p>We are also using a concept <em>pretty close to the view contract in Spark</em>, thus enabling the separation of concerns between the designer and the developer. </p>
<p><img style="margin: 0 0 0 0;" title="flit-and-flex" src="http://npacemo.com/wordpress/wp-content/uploads/2009/06/flit-and-flex.png" alt="FLit is Flex" width="500" height="281" /></p>
<h3>What do we mean by lite?</h3>
<p>We understand liteness as to have minimum dependencies between components, thus there are no components in the framework that will induce as dependencies a substantial part of the framework itself. </p>
<p>We understand liteness as the ability to include only those concern that interest you and not some behavior hard-coded in the framework. </p>
<p>We also understand liteness as having a lite build process. Previously when building custom Flash apps we needed to use the designer machine and the designer productivity tools for the build. With FLit this is not the case - the designer is responsible only in preparing assets that must contain the parts specified in the view contract, so the productivity tools are not used for the build. So, this is also a pretty lite skinning process.<br />
<img style="margin: 0 0 0 0;" title="flit-lite" src="http://npacemo.com/wordpress/wp-content/uploads/2009/06/flit-lite.png" alt="FLit is lite" width="500" height="281" /></p>
<h3>The current state of FLit</h3>
<p>FLit is in early experimentation phase. Maybe <a href="http://dev.obecto.com/flit_samples/FormSample.html">this sample</a> somewhat summarizes what&#8217;s inside the framework now? You can also check out <a href="http://code.google.com/p/flit/source/browse/trunk/sampleComponents/src/component/flit/form/FlitForm.mxml#">the sample&#8217;s code</a>!<br />
A summary of features:</p>
<p style="margin-left: 20px;">
● light-weight base component<br />
● light-weight base container<br />
● view contract specification through metadata tags<br />
● skin asset<br />
● several layout strategies<br />
● transition manager that supports declarative transitions between states<br />
● tasks (an idea which originated from the <a href="http://www.gugga.com/GuggaFlashFramework/">GuggaFF</a>) - Sequence and Parallel are also tasks<br />
● declarative input validators<br />
● skin-able button component<br />
● tweening engine</p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2009/06/30/flit-a-light-weight-flex-for-flash-apps/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Physical vs. Metaphorical User Interfaces</title>
		<link>http://npacemo.com/wordpress/2009/03/01/physical-vs-metaphorical-user-interfaces/</link>
		<comments>http://npacemo.com/wordpress/2009/03/01/physical-vs-metaphorical-user-interfaces/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 20:34:31 +0000</pubDate>
		<dc:creator>Vladimir Tsvetkov</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<category><![CDATA[Personal Computing]]></category>

		<category><![CDATA[Benjamin B. Bederson]]></category>

		<category><![CDATA[metaphor]]></category>

		<category><![CDATA[Pad++]]></category>

		<category><![CDATA[physics]]></category>

		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=64</guid>
		<description><![CDATA[We need to hurry up! Personal computing is evolving too slow. It&#8217;s needless to say that the amount of information we need to interact with increases every day. Display dimensions are getting bigger, but this type of scalability is somewhat limited - no matter how big a screen gets it will always be limited to [...]]]></description>
			<content:encoded><![CDATA[<p><strong>We need to hurry up!</strong> Personal computing is evolving too slow. It&#8217;s needless to say that the amount of information we need to interact with increases every day. Display dimensions are getting bigger, but this type of scalability is somewhat limited - no matter how big a screen gets it will always be limited to the <i>viewing frustum</i> of the human eyes. On the other side user interfaces in widespread personal computing are still stuck in the 80&#8217;s. Almost no development at all - nothing more than rudimentary improvements. Even Apple is incrementing too slow over it. </p>
<p/>
The thing is we&#8217;re still mimicking early media types and no one (neither Apple or Microsoft, or even free software initiatives) have the guts to leave behind old paradigms and move to radically new user interface <i>mechanisms</i>. </p>
<p/>
Some say a radically new user interfaces would be <i>unintuitive</i> and <i>unnatural</i>, but the adverb <i>intuitive</i> in nothing more than a reference to someone&#8217;s level of acquaintance or past experience with a concept. This simply means that in order to feel comfortable with a system you need to be relatively experienced with similar systems. But what are the options when most of the systems are poorly designed? To design an intuitive system we need to repeat the design flaws of the previous systems our potential users were exposed to. So maybe we should not set intuitiveness as a goal, but instead <strong>focus on human cognetics and solid scientific principles</strong> when exploring new possibilities for user interfaces.</p>
<p/>
Some say there is no business for radical changes, especially in times of crisis. People want something that has already been proven useful. There is no margin for risks&#8230; So, I&#8217;m going to publish a comparison between current metaphorical user interfaces with an alternative one that relies on information physics. </p>
<p/>
My points of view about personal computer user interfaces are strongly influenced by Jef Raskin&#8217;s book <i>The Humane Interface</i>. In his book he wrote about the application of <i>Zoomable User Interfaces</i> and he also referred to the research work done in this field by Benjamin B. Bederson with the Pad++ software at the University of New Mexico. Currently the information about <a href="http://www.cs.umd.edu/hcil/pad++/">Pad++</a> is moved to the web pages of the University of Maryland, where you can find a handful of <a href="http://www.cs.umd.edu/hcil/pad++/papers/">useful papers</a> (a must-read for everyone interested in designing and developing ZUI&#8217;s). I&#8217;ve recently found this comparison in the last pages of a <a href="http://www.cs.umd.edu/hcil/pad++/papers/uist-94-pad/uist-94-pad.pdf">paper</a> titled <i>Pad++: A Zooming Graphical Interface for Exploring Alternate Interface Physics</i>. I&#8217;ll publish the comparison with just minor modifications.</p>
<h3>Four distinguishing differences</h3>
<p>A physical interface strategy can be distinguished in at least four ways from a metaphor based strategies:</p>
<p/>
<strong>First</strong>, metaphors necessarily pre-exist their use. Pre-Copernicans could never have used the metaphor of the solar system for describing the atom. In designing interfaces, one is limited to metaphorical resources at hand. In addition, the metaphorical reference must be familiar to work. An unfamiliar interface metaphor in functionally no metaphor at all. One can never design metaphor the way one can design self-consistent physical descriptions of appearance and behavior. Thus, as an interface design strategy physics offer design-ability and tailor-ability that metaphor does not. </p>
<p/>
<strong>Second</strong>, metaphors are temporary bridging concepts. When they become ubiquitous, they die. The familiarity provided by the metaphor during earlier stages of uses gives way to familiarity with the interface due to actual experience. The current generation of kids have grew up with personal computers around them and a world of desktops, files and menus, but even though these are metaphors, and are also a successful ones, to these kids a desktop is just a computer screen and a file is just something on a hard drive with no mental association with the real life entities originally used for the metaphors. Successful metaphors also wind up as dead metaphors. But the pervasiveness of dead metaphors as files, menus, and windows may well restrict us from thinking about alternative organizations of computation.</p>
<p/>
<strong>Third</strong>, since the sheer amount and complexity of information with which we need to interact continues to grow, we require design strategies that <i>scale</i>. Metaphor is no such a scaling strategy. Physics is. Physics scales to organize greater and greater complexity by uniform application of sets of simple laws. In contrast, the greater the complexity of metaphorical reference, the less likely it is that any particular structural correspondence between metaphorical target and reference will be useful.</p>
<p/>
<strong>Fourth</strong>, it is clear that metaphors can be harmful as well as helpful since they may well lead users to import knowledge not supported by the interface. There are certainly metaphorical aspects associated with physics-based strategy. <strong>Our point is not that metaphors are not useful but that they may restrict the range of interfaces we consider. </strong></p>
<p>What do you think about this?<br />
Tell me, what you want to be able to do with your personal computers and what user interfaces you would like to have?</p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2009/03/01/physical-vs-metaphorical-user-interfaces/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Thoughts on Creating an Open Company</title>
		<link>http://npacemo.com/wordpress/2008/12/22/thoughts-on-creating-an-open-company/</link>
		<comments>http://npacemo.com/wordpress/2008/12/22/thoughts-on-creating-an-open-company/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 14:20:13 +0000</pubDate>
		<dc:creator>Vladimir Tsvetkov</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[Design]]></category>

		<category><![CDATA[entrepreneurship]]></category>

		<category><![CDATA[obecto]]></category>

		<category><![CDATA[open]]></category>

		<category><![CDATA[sustainability]]></category>

		<category><![CDATA[The Cluetrain Manifesto]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=61</guid>
		<description><![CDATA[Beware, this post has only questions and no answers but just a few suggestions coming out of my no-experience-at-all-in-creating-and-running-businesses. But guess what? It&#8217;s open, so feel free to come in and take part in the discussion.

Where to start from? A month or so somebody had twitted a book about the revolutionary changes happening over the [...]]]></description>
			<content:encoded><![CDATA[<p>Beware, this post has only questions and no answers but just a few suggestions coming out of my no-experience-at-all-in-creating-and-running-businesses. But guess what? It&#8217;s open, so feel free to come in and take part in the discussion.<br />
<img style="margin: 0 0 0 0;" title="come-in" src="http://npacemo.com/wordpress/wp-content/uploads/2008/12/openness.gif" alt="Come in! We're open" width="500" height="233" /><br />
Where to start from? A month or so somebody had twitted a book about the revolutionary changes happening over the Internet - <a href="http://www.cluetrain.com/">The Cluetrain Manifesto</a> - I took a look at it, read the manifesto, take it to my heart and bookmarked it. I really can&#8217;t remember who suggested me that book, but anyway I want to thank him. It was two days ago when I got back to that bookmark and started reading it and after I read the <a href="http://www.cluetrain.com/apocalypso.html">first chapter</a> it was really difficult for me to get asleep - the voice of the book was amplifying with my brain waves, resulting in a resonance that kept me awake for hours after the time I usually go to bed.</p>
<p/>
The thing is that me and my partner are forming a <a href="http://obecto.com/">company</a> which is focused on building human-centered Rich Internet Applications, but we don&#8217;t want to limit the human centrism only to the applications itself, but to also focus on the humans as the foundation of the whole company. And by humans we don&#8217;t mean consumers, demographics and statistics, but the conscious, valuable beings that are aware of themselves, the environment and the people around them.</p>
<h3>A bit of history</h3>
<p>The conveyor line best characterized the most of the successful businesses of the last century - increasingly detailed division of labour, mindless execution of single repetitive tasks and higher and higher deskilling. We refer to this period of time as to the Industrial Era, and to this management approach as to Command &#038; Control. While it is great for producing more with less, it&#8217;s simply not humane.</p>
<p/>
If you ask me the industrial era of Command &#038; Control management have died with the fall of the Berlin Wall (this event is not directly related to technology, but adds a dramatic effect) or even a decade before that, but I guess it will take another 20-30 years (hopefully far less than that) to change peoples perception of business as just a shiny polished logo, strong brand with some brainwashing slogans and infinitely repeating advertisements that dumb down the man into a robot (which eventually is substituted by actual robots) on the conveyer line for the purpose of producing and consuming more and more, in order to sustain the company&#8217;s infinite expansion. </p>
<p/>
I&#8217;m a software guy, so I have a natural disgust for Command &#038; Control - it&#8217;s just not the way software is getting done. But no matter how I hate Command &#038; Control, I still can&#8217;t believe how distorted was my perception of business. I thought I need to implement  the &#8220;genius&#8221; idea -  the idea that will bring the fortune to my company, but an idea that is not necessarily improving people&#8217;s lives. And then&#8230; then what? Just keep a nice company image, good financial records, advertise in order not to fossilize and leave everything else to the financiers - they are so good at buying and selling and blowing phony balloons. You may think I write this, because I&#8217;m one of those that hate brokers and bankers and all financiers, but probably I wouldn&#8217;t even thought of them if I haven&#8217;t recently stumbled upon this <a href="http://www.portfolio.com/news-markets/national-news/portfolio/2008/11/11/The-End-of-Wall-Streets-Boom">article</a> - I think Guy Kawasaki twitted about it three or four or five weeks ago and this is how I got to it.</p>
<p/>
Intuitively I knew my perception of business is full of shit, but it took some things to happen before I got my intuition wide awake.</p>
<h3>Sustainability</h3>
<p>I&#8217;ve been thinking for quite some time about the impact my lifestyle has on the environment, but not until a year ago I began to understand what sustainability really means and why it is important. Since then I try to live with the realization that everything I do should somehow fit into the natural environment and not just fit, but also to sustain in it without damaging or destroying it&#8230; or at least I just try to minimize my impact. If you still don&#8217;t know what sustainability is really about, you got to watch the <a href="http://www.ted.com/index.php/talks/william_mcdonough_on_cradle_to_cradle_design.html">William McDonough&#8217;s TED talk</a> to get acquainted with the notions of cradle-to-cradle design.</p>
<h3>Speaking of design&#8230;</h3>
<p>I&#8217;m in the business of making things, so it&#8217;s kind of essential for me to have an accurate understanding of what design is. The cool thing is that if you watch the <a href="http://www.ted.com/index.php/talks/william_mcdonough_on_cradle_to_cradle_design.html">William McDonough TED lecture</a> you&#8217;re not going to learn only about sustainability, but you can also get enlightened on what design is&#8230; and it&#8217;s pretty much everything. By saying that it&#8217;s pretty much everything it&#8217;s my way to emphasize on the importance of the concept of having an intention and to signify this intention with your designs. People think about their desires and needs, but rarely take a minute and try connecting all the dots into a picture that clearly shows their intentions. I was no different&#8230;</p>
<h3>It&#8217;s just scope and scale</h3>
<p>Everything I do or have done had a meaning in the context of my actions - graduating a nice university, picking a profession, practice that profession. Sure, professionalism is expected, getting the job done is expected, but nobody expects or requires from you to have intentions out of the scope and the scale of your jobs. It&#8217;s just so Command &#038; Control&#8230; but besides that Command &#038; Control is so inhumane it is also terribly bad for the environment. If you think about your actions, you&#8217;ll see that many of them are justified enough in a particular scope and scale, but in a broader scope and in a bigger scale those same actions are devastating - their signal of intention sounds pretty strange for a reasonable being. It goes something like: &#8220;Let&#8217;s have miserable lives full of stress in a polluted environment where our kids are dying from mercury intoxication.&#8221; Allan Chochinov have put it all together very beautifully in his 1000 words <a href="http://www.core77.com/reactor/04.07_chochinov.asp">Manifesto for Sustainability in Design</a>.</p>
<h3>Designer of a business</h3>
<p>As a beginner entrepreneur I&#8217;m also a designer of a business. It&#8217;s my responsibility to decide what&#8217;s going to be my company&#8217;s signal of intent. It&#8217;s my job to develop a sense of scope and scale for the company, instead of just finding ways to expand. It&#8217;s me who&#8217;s task is to define the company&#8217;s mission, instead of just searching for sources that will fill my pockets. It&#8217;s me and my partners&#8230; and as every other designer, we have specific problems to solve.</p>
<h3>The problem</h3>
<p>Simply put, we need to design a very humane conversation environment for our company. And by humane I mean an environment that responds to the natural human needs and our inclinations to speak freely, show off with the stuff we&#8217;re creating, share our knowledge, learn new things and satisfy our curiosity, but above all to connect and relate with other human beings. </p>
<h3>The common closed model</h3>
<p>The established model among successful companies is to have an intranet hidden behind a firewall and a centralized censorship. The intranet is used for internal discussions, research and development, enterprise management, etc. The firewall takes care of the company&#8217;s discoveries, issues, ideas and dirty underwear not to be released by chance to the public and to keep curious strangers, but mostly to keep potential clients and competition out of the companies internal issues and affairs. The central censorship is disguised under a Public Relations department. The PR guys are concerned only with the company&#8217;s image and this concern has nothing to do with utility or contribution to the greater good, not to mention ethics. It&#8217;s easy and maybe fair to start demonizing the Big Brother and to add a flavor of paranoia, but you should put aside conspiracy theories and start thinking about the reasons that have triggered the emergence of such a model. And the reasons are pretty obvious&#8230; It&#8217;s a matter of basic survival instincts. It looks like living in the constant conditions of competition and rivalry gives power to our most destructive forces. It&#8217;s utopian to expect fair play and ethics out of a dog-eat-dog situation. So, forget about greater good, forget about ethics, forget about basic human needs, forget about the environment and lets focus on screwing each other&#8230; But does it has to be necessarily like this?</p>
<h3>Are there any better alternatives?</h3>
<p>Remember the crazy mathematician from the <a href="http://www.imdb.com/title/tt0268978/">Beautiful Mind</a> movie? Do you remember his name? If you&#8217;ve attended a <a href="http://en.wikipedia.org/wiki/Game_theory">Game Theory</a> course there is no way you&#8217;ve missed or haven&#8217;t remembered his name - <a href="http://en.wikipedia.org/wiki/John_Forbes_Nash">John Forbes Nash Jr.</a> He had mathematically proven that in competitive environments, conflict situations or games, where every player is interested in raising a higher score, the optimal strategy is to reduce competitiveness in favor of cooperation. If all parties agree to such strategy, they&#8217;ll increase their score in the most optimal (least riskier) way and they&#8217;ll reach a point of equilibrium where everyone&#8217;s behavior should remain unchanged in order to gain a sure profit for all parties from such a conflict situation. Businesses apply this theory with their competition, but the sole goal of increasing profit no matter of the social and environmental costs, is pushing people away from businesses and is turning people into their biggest opponent. What used to be statistics, demographics and a gray dumb mass of consumers and employees is now a massive symbiotic system of pervasively interconnected individuals. In our hyper-linked world, we can know anything, anytime. </p>
<p/>
My starting business must acknowledge this eruption of mass awareness and must forge a mutually beneficial strategy that has the potential for large scale collaboration. And to my opinion the first step is to create an entirely open company.</p>
<h3>What&#8217;s an open company?</h3>
<p>I haven&#8217;t done any research on whether there are such companies and I haven&#8217;t even made the effort to search whether an &#8216;open company&#8217; exists as a term. I don&#8217;t know what an open company is, so don&#8217;t expect from me to give you an exact definition. What I can do, is to list some of the characteristics of an open company and also to write down what an open company is not.</p>
<p><span style="border-style: solid; border-width: 1px; margin: 14px; padding: 5px 10px; display: block; background-color: oldLace;">an open company should encourage the emerging Conversation and should not limit discussions only inside the corporate intranet - one way or another the information leakage is inevitable - either an unsatisfied client will expose you as a fraud if you pretend to be something that you&#8217;re not and if your services suck and your products are crap, or either one of your employees will start blogging under a legal disclaimer that will prevent affiliating his writings with the actual company&#8217;s issues</span></p>
<p><span style="border-style: solid; border-width: 1px; margin: 14px; padding: 5px 10px; display: block; background-color: oldLace;">an open company should make use of all emerging information channels in addition to the company&#8217;s established channels - useful feedback can come from virtually everyone and everywhere</span></p>
<p><span style="border-style: solid; border-width: 1px; margin: 14px; padding: 5px 10px; display: block; background-color: oldLace;">an open company should avoid standing in what I call a protective posture - covering its problems, masking company&#8217;s proportions into something completely different or being willing to do anything for a buck - this protective mode prevents companies from actually facing and solving their issues and eventually creating a healthy, worthy, sustainable businesses</span></p>
<p><span style="border-style: solid; border-width: 1px; margin: 14px; padding: 5px 10px; display: block; background-color: oldLace;">an open company should share its knowledge - simple as that</span></p>
<p>And here are some words on what an open company is not:</p>
<p><span style="border-style: solid; border-width: 1px; margin: 14px; padding: 5px 10px; display: block; background-color: oldLace;">an open company is not a reality 24/7 pimp show - company&#8217;s openness is not a desperate attempt for being original - company&#8217;s openness is a tool for discovering and solving issues, sharing knowledge and learning from each other - it is conceptually pure, potentially ethical, but most importantly it looks like a more humane way of making business</span></p>
<h3>The current status</h3>
<p>Right know my venture is wearing the suit of an outsourcing company. Should I be ashamed of that? Strange question you may think, but I wonder is it going to look that strange to you when you come to the realization that it is my company&#8217;s availability, my company&#8217;s competitive prices and it&#8217;s my company&#8217;s higher quality of service that makes possible and it&#8217;s partially responsible for the huge lay offs of programmers and software engineers in the world leading countries. Companies that pretend to be socially responsible may put this legal note on their services:</p>
<p style="font-size: 10px; font-family: Courier; border-style: solid; border-width: 1px; margin: 14px; padding: 5px 10px; display: block;">USE OUR OUTSOURCING SERVICES RESPONSIBLY. ABUSE MAY RESULT IN PEOPLE LOOSING THEIR JOBS, DESTROYING LOCAL ECONOMIES AND EVENTUALLY DESTROYING YOUR WHOLE COMMUNITY.</p>
<p>But on the other side, it&#8217;s me and my partners and our employees who maintain a cheaper lifestyle and restrain our consumer abilities to a level much lower than the level of our american colleagues for instance. This is the nature of the free enterprise system. All of us helped and contributed in establishing this system on a global scale, and now like it or not we&#8217;re in position to constantly compete with each other. I don&#8217;t like it this way. I would rather collaborate than compete with my colleagues, so I&#8217;m in a search of ways to create an open company. I don&#8217;t know if this makes any sense to anyone, but every suggestion and opinion would be appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2008/12/22/thoughts-on-creating-an-open-company/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Adding Directional Motion Blur to APE</title>
		<link>http://npacemo.com/wordpress/2008/11/23/adding-directional-motion-blur-to-ape/</link>
		<comments>http://npacemo.com/wordpress/2008/11/23/adding-directional-motion-blur-to-ape/#comments</comments>
		<pubDate>Sun, 23 Nov 2008 15:58:59 +0000</pubDate>
		<dc:creator>Vladimir Tsvetkov</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[ActionScript 3]]></category>

		<category><![CDATA[ActionScript Physics Engine]]></category>

		<category><![CDATA[APE]]></category>

		<category><![CDATA[Directional Motion Blur]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=58</guid>
		<description><![CDATA[For everyone who wonders what APE is, this is the open source ActionScript Physics Engine for 2D. Basically, with APE you can do the following:

    ● create particles (rectangles, circles, springs, etc.)
    ● configure particles (mass, friction, elasticity, collision, etc.)
    ● connect particles through spring constraints
 [...]]]></description>
			<content:encoded><![CDATA[<p>For everyone who wonders what <a href="http://www.cove.org/ape/">APE</a> is, this is the open source ActionScript Physics Engine for 2D. Basically, with APE you can do the following:</p>
<p style="margin-left: 20px;">
    ● create particles (rectangles, circles, springs, etc.)<br />
    ● configure particles (mass, friction, elasticity, collision, etc.)<br />
    ● connect particles through spring constraints<br />
    ● set particles velocity<br />
    ● add forces to the particles<br />
    ● group particles into groups and compositions
</p>
<p>The code is easy to read and modify and now I&#8217;ll show you, how I&#8217;ve added directional motion blur to some APE components.</p>
<p>Check this sample pendulum which elements are using directional motion blur:</p>
<div style="margin: 20px 0 20px 0; width: 500px; height: 200px;"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="PendulumDemo" width="500" height="200" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><param name="movie" value="http://npacemo.com/sample-applications/bin-release-pendulum/PendulumDemo.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#dddddd" /><param name="allowScriptAccess" value="sameDomain" /><embed src="http://npacemo.com/sample-applications/bin-release-pendulum/PendulumDemo.swf" quality="high" bgcolor="#dddddd" width="500" height="200" name="PendulumDemo" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"></embed></object></div>
<p><a href="http://npacemo.com/sample-applications/APETest.zip">Download the Pendulum source code!</a><br />
<a href="http://npacemo.com/sample-applications/ASPhysicsEngine.zip">Download APE with directional motion blur!</a></p>
<p/>
Adding the directional motion blur to APE is relatively simple, but before doing that we need to understand how to implement directional motion blur with ActionScript.</p>
<h3>What is Directional Motion Blur?</h3>
<p>The Blur filter in Flash can apply blurring only to the right and left or up and down directions of a display object, but not in other directions, like blurring only in 35 degrees direction. This <a href="http://www.senocular.com/flash/source.php?id=0.170">article</a> showed me how can I get by this restriction. </p>
<p><img style="margin-right: 5px;" title="direction-angle" src="http://npacemo.com/wordpress/wp-content/uploads/2008/11/directional-motion-blur-1.jpg" alt="Direction Angle" width="245" height="147" /><img title="rotate" src="http://npacemo.com/wordpress/wp-content/uploads/2008/11/directional-motion-blur-2.jpg" alt="Rotate" width="245" height="147" /><br />
<img style="margin-top: 5px;margin-right: 5px;" title="horizontal-blur" src="http://npacemo.com/wordpress/wp-content/uploads/2008/11/directional-motion-blur-3.jpg" alt="Horizontal Blur" width="245" height="147" /><img style="margin-top: 5px;" title="unrotate" src="http://npacemo.com/wordpress/wp-content/uploads/2008/11/directional-motion-blur-4.jpg" alt="Restore Original Rotation" width="245" height="147" /></p>
<p>1. First, you need to determine the direction angle of the movement. In ActionScript you can get the direction angle in radians with the following calculation:</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
var directionAngle:Number = Math.atan2(endPt.y - startPt.y, endPt.x - startPt.x);
</pre>
<p/>
2. Second, you need to rotate the display object to the negative value of the direction angle. To achieve this you need to rotate the transformation matrix you&#8217;ll use when you draw the bitmap.</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
// reset the rotation matrix:
rotationMatrix.identity();
// rotate the matrix:
rotationMatrix.rotate(-directionAngle);
// set matrix translation:
rotationMatrix.translate(offset, offset);
</pre>
<p/>
3. Third, you draw the bitmap with the already configured transformation matrix and then apply only horizontal blurring with a particular blurring distance.</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
// reset the bitmap data:
blurBitmapData.fillRect(blurRect, 0);
// draw with rotation:
blurBitmapData.draw(originalSprite, rotationMatrix);

// calculate horizontal blur:
var distance:Number = Point.distance(startPt, endPt);
blurFilter.blurX = Math.min(maxBlur, distance * 3);
// apply the blur filter:
blurBitmapData.applyFilter(blurBitmapData, blurRect, blurPoint, blurFilter);
</pre>
<p/>
4. Now, you&#8217;re ready for the final step - restoring the rotation.</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
// the rotation property expects degrees, not radians:
sprite.rotation = directionAngle * 180/Math.PI;
</pre>
<p/>
Here is a sample application demonstrating directional motion blur in action.</p>
<div style="margin: 20px 0 20px 0; width: 500px; height: 200px;"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="DirectionalMotionBlur" width="500" height="200" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><param name="movie" value="http://npacemo.com/sample-applications/bin-release-motionblur/DirectionalMotionBlur.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#dddddd" /><param name="allowScriptAccess" value="sameDomain" /><embed src="http://npacemo.com/sample-applications/bin-release-motionblur/DirectionalMotionBlur.swf" quality="high" bgcolor="#dddddd" width="500" height="200" name="DirectionalMotionBlur" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"></embed></object></div>
<p><a href="http://npacemo.com/sample-applications/DirectionalMotionBlur.zip">Download directional motion blur sample!</a></p>
<h3>Putting All Together in APE</h3>
<p><a href="http://obecto.com">Obecto</a> is bidding for an interesting Flash project, so I had to compile a simple prototype that uses APE for a multi-joint pendulum which elements have a directional motion blur. I&#8217;m not proud the way I did it - I&#8217;ve just done it as quick as possible - directly modifying the <strong>RectangleParticle</strong>, <strong>CircleParticle</strong> and the <strong>SpringConstraint</strong> components of APE. I still haven&#8217;t thought about how to separate the directional motion blur logic into a discrete aspect, neither my implementation is general enough to handle all possible ways of using APE particles (e.q. this implementation does not handle the case when we use a predefined display object instead of a styled rectangle or circle). And may be the worst thing about my implementation is that I&#8217;ve changed the constructors interfaces of the modified components, but this can be fixed quickly.</p>
<p>Have fun with APE for at least a weekend!</p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2008/11/23/adding-directional-motion-blur-to-ape/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Obecto - My New Venture Creation</title>
		<link>http://npacemo.com/wordpress/2008/10/31/obecto-my-new-venture-creation/</link>
		<comments>http://npacemo.com/wordpress/2008/10/31/obecto-my-new-venture-creation/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 23:28:20 +0000</pubDate>
		<dc:creator>Vladimir Tsvetkov</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[entrepreneurship]]></category>

		<category><![CDATA[new venture]]></category>

		<category><![CDATA[obecto]]></category>

		<category><![CDATA[papervision3d]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=56</guid>
		<description><![CDATA[When I started this blog six months ago I haven&#8217;t expected I&#8217;ll quit my job and be part of a startup right now. Moreover, I had no serious reasons to quit my current position in Gugga, except for the growing feeling that I need to find ways to unleash the creativity and initiative power sleeping [...]]]></description>
			<content:encoded><![CDATA[<p>When I started this blog six months ago I haven&#8217;t expected I&#8217;ll quit my job and be part of a startup right now. Moreover, I had no serious reasons to quit my current position in Gugga, except for the growing feeling that I need to find ways to unleash the creativity and initiative power sleeping inside me, and to pursuit the cause I strongly believe in - improving human computer interaction.</p>
<h3>Change</h3>
<p>It gets to a point in life, where a man should decide, whether he&#8217;s going to pursuit his dreams or leave it to the mundane inertia and play it &#8220;safe&#8221;. There were no signs that I&#8217;ve got to this point, but I must say my partner Todor was just about there. His decision to descent to the <i>&#8220;deep, dark canyons of uncertainty and ambiguity&#8221;</i> and his desire to <i>&#8220;walk the breathtaking highlands of success&#8221;</i> inspired me to act. Not to postpone, but to act - right now and right here.<br />
<a href="http://obecto.com"><img style="margin: 20px 0 20px 0;" title="obecto-logo" src="http://npacemo.com/wordpress/wp-content/uploads/2008/10/obecto-logo.png" alt="Obecto Logo" width="500" height="142" /></a><br />
I&#8217;m recognizing a great business opportunity for Obecto to create and shape an amazing new company, but I&#8217;m also seeing a great personal opportunity to develop my character, to learn new things and have the fulfilling experience of being an entrepreneur. Month ago I decided to do my best to make this happen. </p>
<h3>&#8230;and oh boy things are happening really fast</h3>
<p>Almost a month since Todor and I took our decisions and you can already see the results of the efforts taken by us and Obecto&#8217;s associates. We gave the birth of <a href="http://obecto.com/">our corporate web site</a>. To my opinion, the design is simplistic, but yet elegant. I&#8217;ll leave to you the comments. Every feedback matters, so please don&#8217;t hesitate.<br />
<a href="http://obecto.com"><img style="margin: 20px 0 20px 0;" title="obecto-site" src="http://npacemo.com/wordpress/wp-content/uploads/2008/10/obecto-site.jpg" alt="Obecto Site" width="500" height="246" /></a></p>
<h3>Some words about technology</h3>
<p>Our site is written in Flex and it uses <a href="http://blog.papervision3d.org/">Papervision3D</a>. For everyone interested, the code of the site is going to be published soon. Right now, we&#8217;re too embarrassed to share the stuff we wrote so quickly late in the night (both of us are for four more days on a payroll at Gugga) and just don&#8217;t want to leave you with a bad impressions.</p>
<h3>A chance to thank</h3>
<p>I want to thank Gugga and to all my colleagues there. These 3 years I learned a lot from you guys. Keep up with the good work!</p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2008/10/31/obecto-my-new-venture-creation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Introduction to Flex Application&#8217;s Architecture - Part 3 - The Gugga Approach</title>
		<link>http://npacemo.com/wordpress/2008/10/03/introduction-to-flex-applications-architecture-part-3-the-gugga-approach/</link>
		<comments>http://npacemo.com/wordpress/2008/10/03/introduction-to-flex-applications-architecture-part-3-the-gugga-approach/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 16:34:56 +0000</pubDate>
		<dc:creator>Vladimir Tsvetkov</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[Adobe Flex]]></category>

		<category><![CDATA[architecture]]></category>

		<category><![CDATA[flex]]></category>

		<category><![CDATA[introduction]]></category>

		<category><![CDATA[mvc]]></category>

		<category><![CDATA[mvcs]]></category>

		<category><![CDATA[OpenFlux]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=53</guid>
		<description><![CDATA[While in part 2 I had discussed the role of the Mediator in the PureMVC framework, Jesse Warden wrote a very intimate article about his experience with Cairngorm and PureMVC - No Mediator vs. No Singleton in Cairngorm &#038; PureMVC - thus reminding me that I need to emphasize more on the important role of [...]]]></description>
			<content:encoded><![CDATA[<p>While in <a href="http://npacemo.com/wordpress/2008/06/08/introduction-to-flex-applications-architecture-part-2-puremvc/">part 2</a> I had discussed the role of the <strong>Mediator</strong> in the PureMVC framework, Jesse Warden wrote a very intimate article about his experience with Cairngorm and PureMVC - <a href="http://jessewarden.com/2008/09/no-mediator-vs-no-singleton-in-cairngorm-puremvc.html">No Mediator vs. No Singleton in Cairngorm &#038; PureMVC</a> - thus reminding me that I need to emphasize more on the important role of the Mediator. </p>
<h3>More on the Mediator</h3>
<p>In my previous article I was describing the need to have an agent near the View in order to handle complex user interaction instead of running the whole cycle of processing Cairngorm events, but most importantly to make possible View reuse. To make something reusable it should be abstract as possible - this means not only removing any business specific logic from the View-component, but also to reduce the necessity to imbue other application components with certain knowledge about this View-component. The lesser they need to know about it, the better. So far, so good, but I&#8217;ve omitted and missed entirely to write about <strong>Mediators as translators</strong>. Removing business specific logic from the View-components, means that the View-specific events should be mapped to business logic events. As you might guess the Mediator is the dude performing this so important mapping - it intercepts the View specific events and then dispatches the corresponding business specific events that usually trigger Command execution.<br />
The bitch in Cairngorm is the lack of a Mediator. Novices do dispatch Cairngorm events directly from the View-components, thus making these components not very reusable - sometimes you might be able to reuse them in other Cairngorm applications, but you have to be careful not to duplicate an already existing Cairngorm event. In the above mentioned article Jesse Warden suggested that Cairngorm needs a formalized concept for a Mediator, just as in PureMVC. I agree on that, but later in this article I will describe an approach bit more natural to Flex.</p>
<p/>
I won&#8217;t contribute to the second part of the discussion started by Jesse about the pros and cons of using singletons first because I agree with his point of view and second because as being such a fundamental and well known and widely used pattern its value or harm to application architectures have been discussed thoroughly. </p>
<h3>The Gugga Approach</h3>
<p>In the rest of the article I&#8217;ll write about the approach we use in the company I work for - it is not something new - I&#8217;ll write about things that have been around in the Flex community for a while and have been used successfully by plethora of Flex practitioners.<br />
In <a href="http://npacemo.com/wordpress/2008/05/28/introduction-to-flex-applications-architecture-part-1-cairngorm/">part 1</a> and <a href="http://npacemo.com/wordpress/2008/06/08/introduction-to-flex-applications-architecture-part-2-puremvc/">part 2</a> I&#8217;ve been showing you couple of architectures you can use almost right away as skeletons for your applications, but those architectures are way to <strong>MACRO</strong> to deal with the real challenges in building RIAs - user experience, human computer interaction and custom UI components - these are impossible to deal with using a <strong>MACRO</strong> approach. Sure, application architectures are important, but as soon as you gain the experience, you&#8217;ll start designing your own custom tailored application specific architectures, just like the sample architecture on the simple diagram below:<br />
<img style="margin: 20px 0 20px 0;" title="custom-architecture-diagram" src="http://npacemo.com/wordpress/wp-content/uploads/2008/10/custom-architecture-diagram.jpg" alt="Cairngorm Diagram" width="500" height="291" /><br />
On the diagram I&#8217;m showing couple of Flex modules or just Flex components, which are implementing the <strong>MVC</strong> or <strong>MVCS (Model View Controller Service)</strong> patterns, but not in the terms of PureMVC or Cairngorm - I&#8217;ll get into more detail in the next section. The <strong>Application Controller</strong> manages the life-cycle of these modules and it is also responsible for catching application specific events from the modules, injecting the needed data for the modules, controlling the transitions between modules and updating the business specific data, which is kept in synch with the help of a <strong>Data Manager</strong>. This is a rather <strong>MACRO MVC</strong> architecture - where the <strong>Model</strong> is comprised by data and a Data Manager, the <strong>View</strong> is composed by modules, and the <strong>Controller</strong> is the thick thing in the middle.</p>
<h3>An Architectural Blueprint for Flex Applications</h3>
<p>Almost two years ago Joe Berkovitz wrote <a href="http://www.adobe.com/devnet/flex/articles/blueprint.html">an article for the Adobe DevNet</a> which to my opinion had a deep influence not only on a <strong>MACRO</strong>-level as a prescription for Flex application architectures, but also on a more <strong>MICRO</strong>-level as a blueprint for engineering Flex modules and Flex components. The realization that this <strong>MVCS</strong> approach is applicable in making Flex components didn&#8217;t came at once - it took us almost a year of building custom Flex components to discover the bitter truth that Flex framework UI components are not designed in the best way to cope with the broad spectrum of customization requirements. The current design and implementation bundles the core functionality of a component with an almost hard-coded view, thus forming a complex monolithic component. So instead of having a flexible way of customizing the view and the behavior through smart usage of inversion of control and dependency injection, right now the developer is constrained with overriding existing functionality and very often the sole possible way of getting the job done is to copy and modify code from the Flex framework. Off course the new versions of the Flex framework will introduce more and more improvements - the changes for the next version wouldn&#8217;t be that drastic as I want, but still they will address the most painful problems.</p>
<p/>
Instead of summarizing <a href="http://www.adobe.com/devnet/flex/articles/blueprint.html">the blueprint proposed by Joe Berkovitz</a>, I&#8217;ll show you a real MVCS-implementation, but before that you need to know what is inversion of control and how to use dependency injection in Flex.</p>
<h3>Inversion of Control (IoC) Patterns</h3>
<p><strong>IoC</strong> patterns have two major goals - reducing class dependencies and extracting the creational logic and the components dependencies management outside the component. Let&#8217;s take for example this short code fragment:</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
package com.sample
{
    public class Loader
    {
        public function load() : void
        {
            ...
            var bar : IBar = new LoopingProgressBar();
            ...
        }
    }
}
</pre>
<p>This piece of code looks all right to the point when we decide to change the looping progress bar with a download progress bar. First the <strong>Loader</strong> has no core functionality changes what so ever, but because of this small change of the progress bar, we&#8217;ll end up messing with the <strong>Loader</strong>&#8217;s code and eventually it will need another compilation. Another way of doing this is to decouple the creational logic and use dependency injection as a form of runtime configuration of the <strong>Loader</strong>. </p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
package com.sample
{
    public class Loader
    {
        private var _bar : IBar;
        public function set bar(value : IBar) : void
        {
            _bar = value;
        }
        public function get bar() : IBar
        {
            return _bar;
        }

        public function load() : void
        {
            ...
            // using the injected IBar-reference
            ...
        }
    }
}
</pre>
<p>In the code above I&#8217;m using the so called <strong>setter dependency injection</strong>, thus someone outside the <strong>Loader</strong> component will need to care about creating and injecting the proper progress bar instance, instead of hard-coding it inside the component. To be able to do that we need to use interfaces (or the most abstract form available) instead of concrete classes - this is how we avoid class dependencies. </p>
<h3>MVCS with Inversion of Control</h3>
<p>The way we do IoC in Flex is related to the Flex UI component life-cycle and the way in which the Flex data binding is triggered. We use these mechanisms instead of having a sophisticated IoC-containers, which is great because you don&#8217;t need to learn any new API. Actually you don&#8217;t really need to learn anything new if you&#8217;re already familiar with data binding and the Flex UI component life-cycle.</p>
<p/>
Let&#8217;s take a look at a typical <strong>MICRO-MVCS</strong>:</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
&lt;gallery:PhotoGalleryClass xmlns:gallery="com.sample.gallery.*"&gt;
    &lt;gallery:Model id="model"/&gt;
    &lt;gallery:Controller id="controller" model="{model}" service="{service}"/&gt;
    &lt;gallery:View id="view" model="{model}"
        nextPhoto="controller.loadNextPhoto();"
        prevPhoto="controller.loadPrevPhoto();"/&gt;
    &lt;gallery:Service id="service"/&gt;
&lt;/gallery:PhotoGalleryClass&gt;
</pre>
<p>This is the <strong>PhotoGallery.mxml</strong> component which inherits the <strong>PhotoGalleryClass</strong> as a form of a &#8220;code behind&#8221;. This component consists of a Model, a Service, a Controller that is injected with the Model and Service instances, and a View which is data bound to the Model. The <strong>nextPhoto</strong> and <strong>prevPhoto</strong>-events dispatched from the View are handled by invoking the Controller methods <strong>loadNextPhoto()</strong> or <strong>loadPrevPhoto()</strong> - these methods are using the Service to obtain from a remote destination the next or the previous photo in the gallery and to update the Model with the newly received data. The data binding between the View and the Model will automatically trigger the View updates.</p>
<p/>
Simple, huh? And all parts of this composition are potentially reusable. </p>
<p/>
This type of micro-MVC is getting more and more popular. The <a href="http://openflux.googlecode.com">OpenFlux</a> component framework is using a very similar architecture for every component in the framework, so it&#8217;s pretty convincing that this simple MVC combined with the power of IoC can be applied on different level of granularity, like for example the <strong>PhotoGallery.mxml</strong> can be a whole module or a whole application, or much simpler custom component. Ben Stucki wrote a very nice <a href="http://www.insideria.com/2008/06/getting-started-with-openflux.html">introduction to OpenFlux</a> and I recommend you reading it. It is a very brief introduction, so it will take you less than 5 minutes to learn some very powerful concepts. You&#8217;ll notice that in <strong>OpenFlux</strong> there is no formalized Model, but if you think about it in most of the cases a change in the Model is very often coupled with a change in the component functionality, so this probably led to the decision to use the component itself as the Model for <strong>OpenFlux</strong> components.</p>
<h3>Conclusion</h3>
<p>Both Cairngorm and PureMVC originate from technologies which are not Flex, but Flex has some very powerful features like declarative style of programming inside the MXML and Data Binding. These combined with the UIComponent life-cycle gives us the functionality of something like an IoC-container. Getting more experienced with Flex will help us find much simpler and more powerful ways of using this IoC capabilities, which eventually will lead to designing application architectures more natural to Flex.</p>
<h3>Reference</h3>
<p><a href="http://www.adobe.com/devnet/flex/articles/blueprint.html">An Architectural Blueprint for Flex Applications</a> by Joe Berkovitz<br />
<a href="http://www.insideria.com/2008/06/getting-started-with-openflux.html">An Introduction to OpenFlux</a> by Ben Stucki<br />
<a href="http://openflux.googlecode.com">OpenFlux</a> is an open-source component framework for Flex which makes radically custom component development fast and easy.</p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2008/10/03/introduction-to-flex-applications-architecture-part-3-the-gugga-approach/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
