<?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>Labråtens Web Log</title>
	<atom:link href="http://www.labraaten.com/wpblog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.labraaten.com/wpblog</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Sun, 16 Nov 2008 23:45:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Mobile earthquake screensaver for your Sony-Ericsson</title>
		<link>http://www.labraaten.com/wpblog/2008/06/02/mobile-earthquake-screensaver-for-your-sony-ericsson/</link>
		<comments>http://www.labraaten.com/wpblog/2008/06/02/mobile-earthquake-screensaver-for-your-sony-ericsson/#comments</comments>
		<pubDate>Sun, 01 Jun 2008 23:00:55 +0000</pubDate>
		<dc:creator>Petter Labråten</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[810i]]></category>

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

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

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

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

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

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

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

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

		<category><![CDATA[sony-ericsson]]></category>

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

		<guid isPermaLink="false">http://www.labraaten.com/wpblog/?p=295</guid>
		<description><![CDATA[Inspired by the recent earthquake on Iceland measuring 6.1 on Richters Scale (and possibly the 7.9&#8242;er in Kina) I decided to create my own earthquake screensaver for my Sony Ericsson 810i.
For those of you interessted in seismic activity in and around Norway feel free to download the source or binaries here.
Binaries:
http://www.labraaten.com/wpblog/wp-content/2008/06/EarthQuake.jad
Source:
EarthQuake.java
EarthQuakeCanvas.java
- Petter
]]></description>
			<content:encoded><![CDATA[<p>Inspired by the recent earthquake on Iceland measuring 6.1 on Richters Scale (and possibly the 7.9&#8242;er in Kina) I decided to create my own earthquake screensaver for my Sony Ericsson 810i.</p>
<p>For those of you interessted in seismic activity in and around Norway feel free to download the source or binaries here.</p>
<p>Binaries:<br />
<a href="http://www.labraaten.com/wpblog/wp-content/2008/06/EarthQuake.jad">http://www.labraaten.com/wpblog/wp-content/2008/06/EarthQuake.jad</a></p>
<p>Source:<br />
<a href="http://www.labraaten.com/wpblog/wp-content/2008/06/EarthQuake.java">EarthQuake.java</a><br />
<a href="http://www.labraaten.com/wpblog/wp-content/2008/06/EarthQuakeCanvas.java">EarthQuakeCanvas.java</a></p>
<div style="text-align: right">- Petter</div>
]]></content:encoded>
			<wfw:commentRss>http://www.labraaten.com/wpblog/2008/06/02/mobile-earthquake-screensaver-for-your-sony-ericsson/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Thailand 2008</title>
		<link>http://www.labraaten.com/wpblog/2008/05/06/131/</link>
		<comments>http://www.labraaten.com/wpblog/2008/05/06/131/#comments</comments>
		<pubDate>Tue, 06 May 2008 19:34:22 +0000</pubDate>
		<dc:creator>Petter Labråten</dc:creator>
		
		<category><![CDATA[Gallery]]></category>

		<guid isPermaLink="false">http://www.labraaten.com/wpblog/2008/05/06/131/</guid>
		<description><![CDATA[In January, me, my girlfriend and some otherfriends went on a backpacking trip to Thailand. Here are some pictures. Enjoy&#8230; I did  





























]]></description>
			<content:encoded><![CDATA[<div><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_8393-1-150x150.jpg" alt="Coconut Palm, Kho Tao" title="Coconut Palm, Kho Tao" width="75" height="75" class="alignleft size-thumbnail wp-image-164" />In January, me, my girlfriend and some otherfriends went on a backpacking trip to Thailand. Here are some pictures. Enjoy&#8230; I did <img src='http://www.labraaten.com/wpblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </div>
<p><span id="more-131"></span><br />
<br/><br/><br />

<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7468-1/' title='Joy Bungalow'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7468-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_8523-1/' title='Me and a &#039;thing&#039;.'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_8523-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_8514-1/' title='Hotel Lebua, Bangkok'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_8514-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_8513-1/' title='Hotel Lebua, Bangkok'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_8513-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_8464-1/' title='Leaving Kho Tao'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_8464-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_8435-1/' title='Car Bar, Kho Tao'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_8435-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_8393-1/' title='Coconut Palm, Kho Tao'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_8393-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_8377-1/' title='Drinking Singha?'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_8377-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_8198-1/' title='Changover?'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_8198-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7815-1/' title='Me and some friends, Krabi.'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7815-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7810-1/' title='&quot;Beware of the monkeys&quot; sign in Krabi'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7810-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7786-1/' title='Tiger Temple, Krabi'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7786-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7742-1/' title='Fish, Kho Phi Phi Don'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7742-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7733-1/' title='More fish, Kho Phi Phi Don'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7733-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7694-1/' title='Me as a fish, Kho Phi Phi Don'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7694-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7563-1/' title='Coconut milk goes with anything'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7563-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7559-1/' title='Rubber'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7559-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7556-1/' title='Those coconuts...'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7556-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7534-1/' title='Endless beach'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7534-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7530-1/' title='Tsunami Warning Sign, Kho Jam'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7530-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7528-1/' title='Endless beach in opposite direction'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7528-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7496-1/' title='img_7496-1'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7496-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7493-1/' title='img_7493-1'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7493-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7475-1/' title='Humane way of removing moskitos'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7475-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.labraaten.com/wpblog/2008/05/06/131/img_7469-1/' title='Holiday :)'><img src="http://www.labraaten.com/wpblog/wp-content/2008/05/img_7469-1-150x150.jpg" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.labraaten.com/wpblog/2008/05/06/131/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sodoko, sodoku, suduko, sudoku!</title>
		<link>http://www.labraaten.com/wpblog/2008/05/01/sodoko-sodoku-suduko-sudoku/</link>
		<comments>http://www.labraaten.com/wpblog/2008/05/01/sodoko-sodoku-suduko-sudoku/#comments</comments>
		<pubDate>Thu, 01 May 2008 22:25:23 +0000</pubDate>
		<dc:creator>Petter Labråten</dc:creator>
		
		<category><![CDATA[Misc]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://www.labraaten.com/wpblog/2008/05/01/sodoko-sodoku-suduko-sudoku/</guid>
		<description><![CDATA[Like any other serious website www.labraaten.com now has its own Sudoku! Wee! Just click a &#8217;square&#8217; and enter a number.




Like a non-digital Sudoku you won&#8217;t get any help. It won&#8217;t even tell you if you succeed or not (not until version 2.0 that is). Reload the page to generate a new game.

The applet is a [...]]]></description>
			<content:encoded><![CDATA[<p>Like any other serious website www.labraaten.com now has its own Sudoku! Wee! Just click a &#8217;square&#8217; and enter a number.<br />
<span id="more-89"></span></p>
<p><center><br />
<applet archive="http://www.labraaten.com/wpblog/wp-content/pididoku.jar" code="net/sourceforge/playsudoku/Pididoku.class" width="273" height="237"></applet><br />
</center><br />
Like a non-digital Sudoku you won&#8217;t get any help. It won&#8217;t even tell you if you succeed or not (not until version 2.0 that is). Reload the page to generate a new game.<br />
<br/><br />
The applet is a stripped and customized version of the GPL project <a href="http://playsudoku.sourceforge.net/">Java Sudoku</a>. You can get my modified sourcecode <a href='http://www.labraaten.com/wpblog/wp-content/pididoku.rar' title='pididoku.rar'>here</a>.<br />
<br/></p>
<p style="text-align: right">-petter</p>
]]></content:encoded>
			<wfw:commentRss>http://www.labraaten.com/wpblog/2008/05/01/sodoko-sodoku-suduko-sudoku/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Protected: Schnapps &#038; Schnee 2009</title>
		<link>http://www.labraaten.com/wpblog/2008/04/27/schnapps-und-schnee-2009/</link>
		<comments>http://www.labraaten.com/wpblog/2008/04/27/schnapps-und-schnee-2009/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 11:13:42 +0000</pubDate>
		<dc:creator>Petter Labråten</dc:creator>
		
		<category><![CDATA[Schnee]]></category>

		<guid isPermaLink="false">http://www.labraaten.com/wpblog/2008/04/27/schnapps-und-schnee-2009/</guid>
		<description><![CDATA[There is no excerpt because this is a protected post.]]></description>
			<content:encoded><![CDATA[<form action="http://www.labraaten.com/wpblog/wp-pass.php" method="post">
<p>This post is password protected. To view it please enter your password below:</p>
<p><label for="pwbox-86">Password:<br />
<input name="post_password" id="pwbox-86" type="password" size="20" /></label><br />
<input type="submit" name="Submit" value="Submit" /></p></form>
]]></content:encoded>
			<wfw:commentRss>http://www.labraaten.com/wpblog/2008/04/27/schnapps-und-schnee-2009/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Avoid those unnecessary for-loops&#8230;</title>
		<link>http://www.labraaten.com/wpblog/2008/04/04/avoid-those-unnecessary-for-loops/</link>
		<comments>http://www.labraaten.com/wpblog/2008/04/04/avoid-those-unnecessary-for-loops/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 14:33:31 +0000</pubDate>
		<dc:creator>Petter Labråten</dc:creator>
		
		<category><![CDATA[VB]]></category>

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

		<category><![CDATA[Convert.ToInt32]]></category>

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

		<category><![CDATA[String.Split]]></category>

		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.labraaten.com/wpblog/2008/04/04/avoid-those-unnecessary-for-loops/</guid>
		<description><![CDATA[One thing that makes my - and others - code look ugly are all those for-loops repeatedly embedded into the code.
A typical example ias converting a string of comma seperated numbers into an array of integers. Here&#8217;s how to do it in one statement, without any loop:

Dim str As String = "1,2,3,4,5"
Dim ints As Integer() [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that makes my - and others - code look ugly are all those for-loops repeatedly embedded into the code.</p>
<p>A typical example ias converting a string of comma seperated numbers into an array of integers. Here&#8217;s how to do it in one statement, without any loop:</p>
<pre class="code">
Dim str As String = "1,2,3,4,5"
Dim ints As Integer() = Array.ConvertAll(Of String, Integer)(str.Split(","), _
    AddressOf Convert.ToInt32)
</pre>
<div style="text-align:right">- petter</div>
<p><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.labraaten.com/wpblog/2008/04/04/avoid-those-unnecessary-for-loops/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How can I access a protected member from a derived class?</title>
		<link>http://www.labraaten.com/wpblog/2008/04/01/how-can-i-access-a-protected-member-from-a-derived-class/</link>
		<comments>http://www.labraaten.com/wpblog/2008/04/01/how-can-i-access-a-protected-member-from-a-derived-class/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 00:19:38 +0000</pubDate>
		<dc:creator>Petter Labråten</dc:creator>
		
		<category><![CDATA[C#]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://www.labraaten.com/wpblog/2008/04/01/how-can-i-access-a-protected-member-from-a-derived-class/</guid>
		<description><![CDATA[First I encountered the error message:

Compiler Error CS1540: Cannot access protected member 'member' via a qualifier
of type 'type1'; the qualifier must be of type 'type2' (or derived from it).

Then I encountered Eric Lipperts explanation of Why Can&#8217;t I Access A Protected Member From A Derived Class?
Then I got angry. And then, after working my emotions [...]]]></description>
			<content:encoded><![CDATA[<p>First I encountered the error message:</p>
<pre class="code">
Compiler Error CS1540: Cannot access protected member 'member' via a qualifier
of type 'type1'; the qualifier must be of type 'type2' (or derived from it).
</pre>
<p>Then I encountered Eric Lipperts explanation of <a href="http://blogs.msdn.com/ericlippert/archive/2008/03/28/why-can-t-i-access-a-protected-member-from-a-derived-class-part-two-why-can-i.aspx">Why Can&#8217;t I Access A Protected Member From A Derived Class?</a></p>
<p>Then I got angry. <span id="more-84"></span>And then, after working my emotions I had to figure out a solution. </p>
<p>Lets start with the example provided by Mr. Lippert:
<pre class="code">
class Ungulate {
  protected void Eat() { /* whatever */ }
}

class Giraffe : Ungulate {
  public static void FeedThem() {
    Giraffe g1 = new Giraffe();
    Ungulate g2 = new Giraffe();
    g1.Eat(); // fine
    g2.Eat(); // <strong>compile-time error &#8220;Cannot access protected member&#8221;</strong>
  }
}
</pre>
<p>The problem here is that the compiler won&#8217;t let you touch g2.Eat() from within the context of Giraffe, simply because all that the compiler knows is that g2 is (or is derived from) an Ungulate. The compiler couldn&#8217;t care less whether or not Giraffe is derived from Ungilate itself. That is protection and - according to the responsible ones - by design.</p>
<p>Anyway, I had to figure a way around. My goal was to ensure future access to the protected method from any derived class. And what was my solution? To add a protected dispatch wrapper (in this case static) around my protected method:</p>
<pre class="code">
class Ungulate {
  protected void Eat() { /* whatever */ }
  <strong>protected static void Eat(Ungulate instance) {
    instance.Eat();</strong>
  }
}

class Giraffe : Ungulate {
  public static void FeedThem() {
    Giraffe g1 = new Giraffe();
    Ungulate g2 = new Giraffe();
    g1.Eat(); // fine
    <strong>Ungulate.Eat(g2);</strong>  // fine aswell
  }
}
</pre>
<p>Breaking some principles of encapsulation? Maybe, but it works like a charm <img src='http://www.labraaten.com/wpblog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p style="text-align: right">-petter</p>
]]></content:encoded>
			<wfw:commentRss>http://www.labraaten.com/wpblog/2008/04/01/how-can-i-access-a-protected-member-from-a-derived-class/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Canine anti-piracy&#8230; anti-bug unit&#8230;</title>
		<link>http://www.labraaten.com/wpblog/2008/03/04/canine-anti-piracy-anti-bug-unit/</link>
		<comments>http://www.labraaten.com/wpblog/2008/03/04/canine-anti-piracy-anti-bug-unit/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 00:03:39 +0000</pubDate>
		<dc:creator>Petter Labråten</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[anti bug]]></category>

		<category><![CDATA[anti piracy]]></category>

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

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

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

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

		<guid isPermaLink="false">http://www.labraaten.com/wpblog/2008/03/04/canine-anti-piracy-anti-bug-unit/</guid>
		<description><![CDATA[If they can find pirated DVDs, then it&#8217;s just a matter of time before they can sniff up buggy, copy&#038;paste code&#8230;
http://news.bbc.co.uk/1/hi/northern_ireland/7275060.stm
- petter
]]></description>
			<content:encoded><![CDATA[<p>If they can find pirated DVDs, then it&#8217;s just a matter of time before they can sniff up buggy, copy&#038;paste code&#8230;</p>
<p><a href="http://news.bbc.co.uk/1/hi/northern_ireland/7275060.stm">http://news.bbc.co.uk/1/hi/northern_ireland/7275060.stm</a></p>
<div style="text-align: right">- petter</div>
]]></content:encoded>
			<wfw:commentRss>http://www.labraaten.com/wpblog/2008/03/04/canine-anti-piracy-anti-bug-unit/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Software development</title>
		<link>http://www.labraaten.com/wpblog/2008/03/01/software-development/</link>
		<comments>http://www.labraaten.com/wpblog/2008/03/01/software-development/#comments</comments>
		<pubDate>Sat, 01 Mar 2008 04:23:07 +0000</pubDate>
		<dc:creator>Petter Labråten</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.labraaten.com/wpblog/2008/03/01/software-development/</guid>
		<description><![CDATA[Here&#8217;s a beatuful illustration of how software development works. It may seem like a joke, but it&#8217;s actually quite accurate.

- petter
]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a beatuful illustration of how software development works. It may seem like a joke, but it&#8217;s actually quite accurate.</p>
<p style="text-align: center"><img src="http://www.labraaten.com/wpblog/wp-content/software-development.jpg" alt="software-development.jpg" /></p>
<p style="text-align:right">- petter</p>
]]></content:encoded>
			<wfw:commentRss>http://www.labraaten.com/wpblog/2008/03/01/software-development/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Generic C# 3.0 Collection Initialization Adapter</title>
		<link>http://www.labraaten.com/wpblog/2008/02/29/a-generic-c-30-collection-initialization-adapter/</link>
		<comments>http://www.labraaten.com/wpblog/2008/02/29/a-generic-c-30-collection-initialization-adapter/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 19:54:14 +0000</pubDate>
		<dc:creator>Petter Labråten</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[.NET]]></category>

		<category><![CDATA[adaptor pattern]]></category>

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

		<category><![CDATA[collection initialization]]></category>

		<category><![CDATA[collection initializers]]></category>

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

		<guid isPermaLink="false">http://www.labraaten.com/wpblog/2008/02/29/a-generic-c-30-collection-initialization-adapter/</guid>
		<description><![CDATA[C# 3.0 comes with this new language feature called Collection Initializaton. It&#8217;s more or less syntactical sugar that simplifies the way you initialize collections.
Where you pre 3.0 would initialize a list of integers like this:

List&#60;int&#62; list = new List&#60;int&#62;();
list.Add(1);
list.Add(2);
list.Add(3);

You now can do this:

List&#60;int&#62; list = new List&#60;int&#62;() {1, 2, 3};

Now, this is somewhat beautified, but [...]]]></description>
			<content:encoded><![CDATA[<p>C# 3.0 comes with this new language feature called Collection Initializaton. It&#8217;s more or less syntactical sugar that simplifies the way you initialize collections.</p>
<p>Where you pre 3.0 would initialize a list of integers like this:</p>
<pre class="code">
List&lt;int&gt; list = new List&lt;int&gt;();
list.Add(1);
list.Add(2);
list.Add(3);
</pre>
<p>You now can do this:</p>
<pre class="code">
List&lt;int&gt; list = new List&lt;int&gt;() {1, 2, 3};
</pre>
<p>Now, this is somewhat beautified, but it does exactly the same as in the first example. The compiler parses the code and calls the Add method, implemented by List&lt;int&gt;, once for every integer in the initialization list.</p>
<p>Now, wouldn&#8217;t this be nice to do on your own proprietary collections? <span id="more-82"></span>Ofcourse. All that&#8217;s needed is for your collection to implement the IEnumerable inteface (for uncertain reasons) and add your own Add function:</p>
<pre class="code">
public class Person
{
    public string Name;
}

public class Family : System.Collections.IEnumerable
{
    List&lt;Person&gt; members;

    public Family()
    {
        this.members = new List&lt;Person&gt;();
    }

    public void Add(Person member)
    {
        members.Add(member);
    }

    // IEnumerable Members
    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        { throw new NotImplementedException(); }
}
</pre>
<p>Then you can initialize a family instance like this:</p>
<pre class="code">
Family family = new Family()
{
    new Person() { Name = "Petter" }
    new Person() { Name = "Kristine" }
};
</pre>
<p>It&#8217;s that simple. Anyway, in my opinion there is just one problem. You don&#8217;t always want to garble your collection with additional interfaces and/or methods just to achieve custom collection initialization. Or maybe you cannot change your collection.<br />
<br/><br />
<strong>So what is the solution?</strong><br />
Well, one solution is to use the adaptor pattern (or maybe it&#8217;s actually the factory pattern) and implement the necessary logic in a seperate adaptor class, then use implicit casting to turn this adaptor class into your target collection. Something like this:</p>
<pre class="code">
abstract class CollectionInitializationAdapter&lt;F,T&gt;
    : System.Collections.IEnumerable where F:new()
{
    protected F collection;

    // Default constructor
    public CollectionInitializationAdapter()
    {
        // Create new instance of target collection
        this.collection = new F();
    }

    // Abstract and implemented by user to fit the target collection
    abstract public void Add(T item);

    // Allows implicit cast to type F (target collection)
    public static implicit operator F(CollectionInitializationAdapter&lt;F, T&gt; f)
    {
        return f.collection;
    }

    // IEnumerable Members
    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
    {
        throw new NotImplementedException();
    }
}
</pre>
<p>Now, to use this abstract generic adaptor class you need to implement it to fit your proprietary collection. That is, implement the Add function:</p>
<pre class="code">
class FamilyInitializator : CollectionInitializationAdapter&lt;Family, Person&gt;
{
    public override void Add(Person item)
    {
        // add the item (person) to the target collections (family) members list
        collection.Member.Add(item);
    }
}
</pre>
<p>And then put it to use:</p>
<pre class="code">
Family family = new FamilyInitializator ()
{
    new Person() { Name = "Petter" },
    new Person() { Name = "Kristine" }
};
</pre>
<p>Wee! Now you got collection initialization for the Family class (or any collection) without adding any interface or changing any code in the collection itself. </p>
<p style="text-align: right">- petter</petter>
]]></content:encoded>
			<wfw:commentRss>http://www.labraaten.com/wpblog/2008/02/29/a-generic-c-30-collection-initialization-adapter/feed/</wfw:commentRss>
		</item>
		<item>
		<title>in·con·sis·tent IIII</title>
		<link>http://www.labraaten.com/wpblog/2008/02/29/in%c2%b7con%c2%b7sis%c2%b7tent-iiii/</link>
		<comments>http://www.labraaten.com/wpblog/2008/02/29/in%c2%b7con%c2%b7sis%c2%b7tent-iiii/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 17:42:01 +0000</pubDate>
		<dc:creator>Petter Labråten</dc:creator>
		
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.labraaten.com/wpblog/2008/02/29/in%c2%b7con%c2%b7sis%c2%b7tent-iiii/</guid>
		<description><![CDATA[When it comes to Visual Studio installation folders, why is it that Microsoft don&#8217;t just settle for one naming convention?
Here it seems that thy&#8217;re not sure what their product is named. Sometimes is .NET, sometimes not. Sometimes by year, sometimes by version (with or without the decimal):
Microsoft Visual Studio .NET 2003
Microsoft Visual Studio 8
Microsoft Visual [...]]]></description>
			<content:encoded><![CDATA[<p>When it comes to Visual Studio installation folders, why is it that Microsoft don&#8217;t just settle for one naming convention?</p>
<p>Here it seems that thy&#8217;re not sure what their product is named. Sometimes is .NET, sometimes not. Sometimes by year, sometimes by version (with or without the decimal):</p>
<p><code>Microsoft Visual Studio .NET 2003<br />
Microsoft Visual Studio 8<br />
Microsoft Visual Studio 9.0</code></p>
<p>At times they find capitalized words totally unnecessary:</p>
<p><code>microsoft frontpage</code></p>
<p>And sometimes a space, sometimes not:</p>
<p><code>Microsoft ASP.NET<br />
Microsoft.NET</code></p>
<p style="text-align: right">- petter</p>
]]></content:encoded>
			<wfw:commentRss>http://www.labraaten.com/wpblog/2008/02/29/in%c2%b7con%c2%b7sis%c2%b7tent-iiii/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

