<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Friso De Ridder</title>
	<atom:link href="http://frisoderidder.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://frisoderidder.wordpress.com</link>
	<description></description>
	<lastBuildDate>Fri, 06 Jan 2012 12:49:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='frisoderidder.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Friso De Ridder</title>
		<link>http://frisoderidder.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://frisoderidder.wordpress.com/osd.xml" title="Friso De Ridder" />
	<atom:link rel='hub' href='http://frisoderidder.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Using phone 7 capability detection tool</title>
		<link>http://frisoderidder.wordpress.com/2011/02/08/using-phone-7-capability-detection-tool/</link>
		<comments>http://frisoderidder.wordpress.com/2011/02/08/using-phone-7-capability-detection-tool/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 01:45:41 +0000</pubDate>
		<dc:creator>frisoderidder</dc:creator>
				<category><![CDATA[Phone 7]]></category>

		<guid isPermaLink="false">http://frisoderidder.wordpress.com/?p=207</guid>
		<description><![CDATA[When you&#8217;re developing a phone 7 application you have access to a wide range of capabilities, they enable access to networking, different sensors on your phone device, identity functionality and so forth. When you create a new phone 7 application in visual studio all of them are enabled, check the &#8216;capabilities&#8217; section in your WMAppManifest.xml [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=207&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When you&#8217;re developing a phone 7 application you have access to a wide range of capabilities, they enable access to networking, different sensors on your phone device, identity functionality and so forth. When you create a new phone 7 application in visual studio all of them are enabled, check the &#8216;capabilities&#8217; section in your WMAppManifest.xml file to see which of them are enabled in your application.</p>
<p>When an application is submitted to the phone marketplace it goes through a submission process. One of the steps in this process is the detection of the required capabilities for that particular application. The submission process also replaces the auto-generated capabilities list with the specific capabilities required for your application.</p>
<p>It is strongly recommended to test applications based on the exact phone capabilities required by the application. Various end-user issues can occur if an application is not tested based on the specific capabilities required by your application.. To make this easy, as of the October 2010 update, a capability detection tool is included in the Windows Phone Developer Tools.</p>
<p>Open a command prompt, go to the folder containing the capability detection tool (Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Tools\CapDetect) and execute the CapabilityDetection.exe with the Rules.xml file and the path to the output folder of your application containing the binaries. After you&#8217;ve run the tool you&#8217;ll get a list of the capabilities needed in your application. Go to the capabilities section of the WMAppManifest.xml file and remove the unnecessary ones.</p>
<p style="text-align:center;"><a href="http://frisoderidder.files.wordpress.com/2011/02/capabilitydetectiontoolinaction2.png"><img class="size-full wp-image-218 aligncenter" title="CapabilityDetectionToolInAction" src="http://frisoderidder.files.wordpress.com/2011/02/capabilitydetectiontoolinaction2.png?w=600&#038;h=249" alt="CapabilityDetectionToolInAction" width="600" height="249" /></a></p>
<p>For more information visit: <a href="http://msdn.microsoft.com/en-us/library/gg180730(v=VS.92).aspx">http://msdn.microsoft.com/en-us/library/gg180730(v=VS.92).aspx</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frisoderidder.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frisoderidder.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frisoderidder.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frisoderidder.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frisoderidder.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frisoderidder.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frisoderidder.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frisoderidder.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frisoderidder.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frisoderidder.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frisoderidder.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frisoderidder.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frisoderidder.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frisoderidder.wordpress.com/207/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=207&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frisoderidder.wordpress.com/2011/02/08/using-phone-7-capability-detection-tool/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08f8c7c243392538b2d5bec4af69af3a?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">frisoderidder</media:title>
		</media:content>

		<media:content url="http://frisoderidder.files.wordpress.com/2011/02/capabilitydetectiontoolinaction2.png" medium="image">
			<media:title type="html">CapabilityDetectionToolInAction</media:title>
		</media:content>
	</item>
		<item>
		<title>Clean up your code behind with behaviors</title>
		<link>http://frisoderidder.wordpress.com/2011/01/22/clean-up-your-code-behind-with-behaviors/</link>
		<comments>http://frisoderidder.wordpress.com/2011/01/22/clean-up-your-code-behind-with-behaviors/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 17:07:38 +0000</pubDate>
		<dc:creator>frisoderidder</dc:creator>
				<category><![CDATA[Phone 7]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://frisoderidder.wordpress.com/?p=164</guid>
		<description><![CDATA[I&#8217;ve been developing in Silverlight for the last two years now however I never got into the habit of using Expression Blend. Three weeks ago I wrote my first Phone 7 application and while developing it, I also forced myself to use blend more often. To be honest in the beginning I was not really fond [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=164&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been developing in Silverlight for the last two years now however I never got into the habit of using Expression Blend. Three weeks ago I wrote my first Phone 7 application and while developing it, I also forced myself to use blend more often. To be honest in the beginning I was not really fond of it, I could write xaml quicker by hand than by setting all the properties in blend, but then I discovered all the extras blend has to offer and I was sold. One of those extras that come with Blend are the build in behaviors for managing storyboards, and let that be the subject of this post.</p>
<p>First I&#8217;ll show you the xaml and code before I was using the behaviors.</p>
<p><pre class="brush: xml; wrap-lines: false;">
&lt;Grid&gt;
    &lt;Grid.Resources&gt;
       &lt;Storyboard x:Name=&quot;SocialSubShowSb&quot;&gt;
            &lt;DoubleAnimation x:Name=&quot;SocialSubShowAnim&quot; Duration=&quot;00:00:00.30&quot; To=&quot;0&quot; Storyboard.TargetProperty=&quot;(UIElement.RenderTransform).(CompositeTransform.TranslateX)&quot; Storyboard.TargetName=&quot;SocialSubscriptionDataContainer&quot; d:IsOptimized=&quot;True&quot; /&gt;
       &lt;/Storyboard&gt;

      &lt;Storyboard x:Name=&quot;SocialSubHideSb&quot;&gt;&lt;br /&gt;
            &lt;DoubleAnimation x:Name=&quot;SocialSubHideAnim&quot; Duration=&quot;00:00:00.30&quot; To=&quot;-700&quot; Storyboard.TargetProperty=&quot;(UIElement.RenderTransform).(CompositeTransform.TranslateX)&quot; Storyboard.TargetName=&quot;SocialSubscriptionDataContainer&quot; d:IsOptimized=&quot;True&quot; /&gt;
        &lt;/Storyboard&gt;

   &lt;/Grid.Resources&gt;
   &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height=&quot;auto&quot; /&gt;
          &lt;RowDefinition Height=&quot;auto&quot; /&gt;
    &lt;/Grid.RowDefinitions&gt;
    
    &lt;controls:YesNoToggleSwitch x:Name=&quot;tsSocialSub&quot; Grid.Row=&quot;0&quot; Header=&quot;{Binding Interpreter.SocialSubscription, Source={StaticResource AppResourceLocator}}&quot; Style=&quot;{StaticResource ToggleSwitchStyle}&quot; IsChecked=&quot;{Binding HasSocialSubscription, Mode=TwoWay}&quot;&gt;  &lt;/controls:YesNoToggleSwitch&gt;

    &lt;Grid x:Name=&quot;SocialSubscriptionDataContainer&quot; Grid.Row=&quot;1&quot; Margin=&quot;15 0 0 0&quot; Visibility=&quot;Collapsed&quot; RenderTransformOrigin=&quot;0.5 0.5&quot;&gt;
        &lt;Grid.RenderTransform&gt;
           &lt;CompositeTransform TranslateX=&quot;-700&quot; /&gt;
        &lt;/Grid.RenderTransform&gt;
        &lt;Grid.RowDefinitions&gt;
           &lt;RowDefinition Height=&quot;auto&quot; /&gt;
           &lt;RowDefinition Height=&quot;auto&quot; /&gt;
           &lt;RowDefinition Height=&quot;auto&quot; /&gt;
        &lt;/Grid.RowDefinitions&gt;

        &lt;toolkit:ListPicker Grid.Row=&quot;0&quot; Header=&quot;{Binding Interpreter.TypeOfTransportation, Source={StaticResource AppResourceLocator}}&quot;                             ItemsSource=&quot;{Binding TypesOfTransport}&quot; SelectedItem=&quot;{Binding SelectedTypeOfTransport, Mode=TwoWay}&quot; Style=&quot;{StaticResource ListPickerStyle}&quot; FullModeHeader=&quot;{Binding Interpreter.TypeOfTransportation, Source={StaticResource AppResourceLocator}}&quot; /&gt;

        &lt;TextBlock Grid.Row=&quot;1&quot; Text=&quot;{Binding Interpreter.SocialSubscriptionMonthlyAmount, Source={StaticResource AppResourceLocator}}&quot; Style=&quot;    {StaticResource PhoneTextSubtleStyle}&quot; /&gt;
            
       &lt;TextBox x:Name=&quot;txtSocialSubMonthAmount&quot; Grid.Row=&quot;2&quot; Text=&quot;{Binding SocialSubscriptionMonthlyAmount, Mode=TwoWay}&quot; Style=&quot;{StaticResource NumberTextboxStyle}&quot; InputScope=&quot;TelephoneNumber&quot; /&gt;
      &lt;/Grid&gt;
&lt;/Grid&gt;
</pre></p>
<p><pre class="brush: csharp;">
public partial class Advantages
{
   public Advantages()
   {
      InitializeComponent();
      SocialSubHideSb.Completed += delegate
            {
                SocialSubscriptionDataContainer.Visibility = Visibility.Collapsed;
            };
      ViewModel.PropertyChanged += OnViewModelPropertyChanged;
   }
   
   private AdvantagesViewModel ViewModel
   {
       get { return (AdvantagesViewModel)DataContext; }
   }
   
   private void OnViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
   {
       if (e.PropertyName == &quot;HasSocialSubscription&quot;)
       {
            if (ViewModel.HasSocialSubscription)
            {
              SocialSubscriptionDataContainer.Visibility = Visibility.Visible;
              SocialSubShowSb.Begin();
             }
             else
             {
               SocialSubHideSb.Begin();
              }
        }
     }
}
</pre></p>
<p>Basically what this code does is, when the toggleswitch gets checked the &#8216;SocialSubscriptionDataContainer&#8217; will become visible and slide in from the left. When the toggleswitch gets unchecked the &#8216;SocialSubscriptionDataContainer&#8217; will slide out of view to the left and when this animation is completed it will collapse.</p>
<p>Now lets rewrite this by using behaviors.</p>
<p><pre class="brush: xml; wrap-lines: false;">
&lt;Grid&gt;
    &lt;Grid.Resources&gt;
       &lt;Storyboard x:Name=&quot;SocialSubShowSb&quot;&gt;
            &lt;DoubleAnimation x:Name=&quot;SocialSubShowAnim&quot; Duration=&quot;00:00:00.30&quot; To=&quot;0&quot; Storyboard.TargetProperty=&quot;(UIElement.RenderTransform).(CompositeTransform.TranslateX)&quot; Storyboard.TargetName=&quot;SocialSubscriptionDataContainer&quot; d:IsOptimized=&quot;True&quot; /&gt;
       &lt;/Storyboard&gt;
       &lt;Storyboard x:Name=&quot;SocialSubHideSb&quot;&gt;
            &lt;DoubleAnimation x:Name=&quot;SocialSubHideAnim&quot; Duration=&quot;00:00:00.30&quot; To=&quot;-700&quot; Storyboard.TargetProperty=&quot;(UIElement.RenderTransform).(CompositeTransform.TranslateX)&quot; Storyboard.TargetName=&quot;SocialSubscriptionDataContainer&quot; d:IsOptimized=&quot;True&quot; /&gt;
        &lt;/Storyboard&gt;
   &lt;/Grid.Resources&gt;
     &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height=&quot;auto&quot; /&gt;
          &lt;RowDefinition Height=&quot;auto&quot; /&gt;
     &lt;/Grid.RowDefinitions&gt;

     &lt;controls:YesNoToggleSwitch x:Name=&quot;tsSocialSub&quot; Grid.Row=&quot;0&quot; Header=&quot;{Binding Interpreter.SocialSubscription, Source={StaticResource AppResourceLocator}}&quot;   Style=&quot;{StaticResource ToggleSwitchStyle}&quot; IsChecked=&quot;{Binding HasSocialSubscription, Mode=TwoWay}&quot;&gt;
           &lt;i:Interaction.Triggers&gt;
             &lt;i:EventTrigger EventName=&quot;Checked&quot;&gt;
               &lt;ic:ChangePropertyAction PropertyName=&quot;Visibility&quot; TargetName=&quot;SocialSubscriptionDataContainer&quot; Value=&quot;Visible&quot; /&gt;
                 &lt;im:ControlStoryboardAction ControlStoryboardOption=&quot;Play&quot; Storyboard=&quot;{StaticResource SocialSubShowSb}&quot; /&gt;
                &lt;/i:EventTrigger&gt;
                &lt;i:EventTrigger EventName=&quot;Unchecked&quot;&gt;
                  &lt;im:ControlStoryboardAction ControlStoryboardOption=&quot;Play&quot; Storyboard=&quot;{StaticResource SocialSubHideSb}&quot; /&gt;
                &lt;/i:EventTrigger&gt;
                &lt;im:StoryboardCompletedTrigger Storyboard=&quot;{StaticResource SocialSubHideSb}&quot;&gt;
                  &lt;ic:ChangePropertyAction PropertyName=&quot;Visibility&quot; TargetName=&quot;SocialSubscriptionDataContainer&quot; Value=&quot;Collapsed&quot; /&gt;
                &lt;/im:StoryboardCompletedTrigger&gt;
             &lt;/i:Interaction.Triggers&gt;
        &lt;/controls:YesNoToggleSwitch&gt;

       &lt;Grid x:Name=&quot;SocialSubscriptionDataContainer&quot; Grid.Row=&quot;1&quot; Margin=&quot;15 0 0 0&quot; Visibility=&quot;Collapsed&quot; RenderTransformOrigin=&quot;0.5 0.5&quot;&gt;
            &lt;Grid.RenderTransform&gt;
                &lt;CompositeTransform TranslateX=&quot;-700&quot; /&gt;
            &lt;/Grid.RenderTransform&gt;
            &lt;Grid.RowDefinitions&gt;
               &lt;RowDefinition Height=&quot;auto&quot; /&gt;
               &lt;RowDefinition Height=&quot;auto&quot; /&gt;
                &lt;RowDefinition Height=&quot;auto&quot; /&gt;
             &lt;/Grid.RowDefinitions&gt;

             &lt;toolkit:ListPicker Grid.Row=&quot;0&quot; Header=&quot;{Binding Interpreter.TypeOfTransportation, Source={StaticResource AppResourceLocator}}&quot;                             ItemsSource=&quot;{Binding TypesOfTransport}&quot; SelectedItem=&quot;{Binding SelectedTypeOfTransport, Mode=TwoWay}&quot; Style=&quot;{StaticResource ListPickerStyle}&quot; FullModeHeader=&quot;{Binding Interpreter.TypeOfTransportation, Source={StaticResource AppResourceLocator}}&quot; /&gt;

            &lt;TextBlock Grid.Row=&quot;1&quot; Text=&quot;{Binding Interpreter.SocialSubscriptionMonthlyAmount, Source={StaticResource AppResourceLocator}}&quot; Style=&quot;    {StaticResource PhoneTextSubtleStyle}&quot; /&gt;

            &lt;TextBox x:Name=&quot;txtSocialSubMonthAmount&quot; Grid.Row=&quot;2&quot; Text=&quot;{Binding SocialSubscriptionMonthlyAmount, Mode=TwoWay}&quot; Style=&quot;{StaticResource NumberTextboxStyle}&quot; InputScope=&quot;TelephoneNumber&quot; /&gt;
      &lt;/Grid&gt;
&lt;/Grid&gt;
</pre></p>
<p>All changes were applied to the toggleswitch, so lets break them down.</p>
<p>To do the &#8216;slide in&#8217; feature I&#8217;ve added an EventTrigger that will listen to the Checked event of the toggleswitch. When this event is triggered two behaviors will be executed the first one is a ChangePropertyAction that will set the visibility property of the SocialSubscriptionContainer to Visible. The second one is a ControlStoryboardAction that will start the &#8216;SocialSubShowSb&#8217; storyboard.</p>
<p>The &#8216;slide out&#8217; feature requires two triggers. The first one is an EventTrigger that will listen to the Unchecked event of the toggleswitch. This trigger will execute ControlStoryboardAction that will start the &#8216;SocialSubHideSb&#8217; storyboard. The second trigger is a StoryboardCompletedTrigger that is configured to listen to the Completed event of the &#8216;SocialSubHideSb&#8217; storyboard. When this trigger is executed a ChangePropertyAction is called that will set the visibility of the SocialSubscriptionContainer to Collapsed.</p>
<p>No lets have a look at the code behind</p>
<p><pre class="brush: csharp;">
   public partial class Advantages
    {
        public Advantages()
        {
            InitializeComponent();
        }
    }
</pre></p>
<p>Woo hoo no code behind!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frisoderidder.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frisoderidder.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frisoderidder.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frisoderidder.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frisoderidder.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frisoderidder.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frisoderidder.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frisoderidder.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frisoderidder.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frisoderidder.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frisoderidder.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frisoderidder.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frisoderidder.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frisoderidder.wordpress.com/164/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=164&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frisoderidder.wordpress.com/2011/01/22/clean-up-your-code-behind-with-behaviors/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08f8c7c243392538b2d5bec4af69af3a?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">frisoderidder</media:title>
		</media:content>
	</item>
		<item>
		<title>Donwload and share process templates for TFS 2010</title>
		<link>http://frisoderidder.wordpress.com/2011/01/20/donwload-and-share-process-templates-for-tfs-2010/</link>
		<comments>http://frisoderidder.wordpress.com/2011/01/20/donwload-and-share-process-templates-for-tfs-2010/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 13:25:02 +0000</pubDate>
		<dc:creator>frisoderidder</dc:creator>
				<category><![CDATA[Team Foundation Server]]></category>

		<guid isPermaLink="false">http://frisoderidder.wordpress.com/?p=158</guid>
		<description><![CDATA[While studying for my TFS 2010 certificate I came across this awesome codeplex page where you can download and share process templates. If you want to see which other templates are available besides the ones installed with TFS 2010. Or you&#8217;re more the &#8216;do-it-yourself&#8217; kinda guy and you want to share your own awesome creations [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=158&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While studying for my TFS 2010 certificate I came across this awesome codeplex page where you can download and share process templates. If you want to see which other templates are available besides the ones installed with TFS 2010. Or you&#8217;re more the &#8216;do-it-yourself&#8217; kinda guy and you want to share your own awesome creations with the rest of the world. This: <a href="http://templex.codeplex.com/">http://templex.codeplex.com/</a> is the place to be.</p>
<p>Cheers<br />
F.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frisoderidder.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frisoderidder.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frisoderidder.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frisoderidder.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frisoderidder.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frisoderidder.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frisoderidder.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frisoderidder.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frisoderidder.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frisoderidder.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frisoderidder.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frisoderidder.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frisoderidder.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frisoderidder.wordpress.com/158/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=158&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frisoderidder.wordpress.com/2011/01/20/donwload-and-share-process-templates-for-tfs-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08f8c7c243392538b2d5bec4af69af3a?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">frisoderidder</media:title>
		</media:content>
	</item>
		<item>
		<title>Important prerequisite for installing a patch for TFS 2O1O</title>
		<link>http://frisoderidder.wordpress.com/2010/09/23/important-prerequisite-for-installing-a-patch-for-tfs-2o1o-if-you-dont-read-this-changes-are-you-are-going-to-die/</link>
		<comments>http://frisoderidder.wordpress.com/2010/09/23/important-prerequisite-for-installing-a-patch-for-tfs-2o1o-if-you-dont-read-this-changes-are-you-are-going-to-die/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 20:26:52 +0000</pubDate>
		<dc:creator>frisoderidder</dc:creator>
				<category><![CDATA[Team Foundation Server]]></category>

		<guid isPermaLink="false">http://frisoderidder.wordpress.com/?p=130</guid>
		<description><![CDATA[Yesterday I wanted to install the following patch for TFS 2010. I went through the kb article, made sure all the prerequisites were met and did a little search for known issues which ended up empty. In the believe it was save, I went ahead with installing the patch on our application tier. The wizard came [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=130&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yesterday I wanted to install the following <a href="http://support.microsoft.com/kb/983578">patch</a> for <a href="http://msdn.microsoft.com/en-us/vstudio/ff637362.aspx">TFS 2010</a>. I went through the kb article, made sure all the prerequisites were met and did a little search for known issues which ended up empty. In the believe it was save, I went ahead with installing the patch on our application tier. The wizard came up, I went through the screens, the patch started installing and 10 minutes later I received a message claiming that the install was succesful. Great I thought &#8230; but then I opened team foundation administration console and I saw the following error appear on my screen.</p>
<p><a href="http://frisoderidder.files.wordpress.com/2010/09/servicingerror.png"><img class="aligncenter size-medium wp-image-131" title="ServicingError" src="http://frisoderidder.files.wordpress.com/2010/09/servicingerror.png?w=300&#038;h=197" alt="ServicingError" width="300" height="197" /></a></p>
<p>There went my smiling face. Nothing worked anymore, TFS was dead.</p>
<p>Fast forwarding 24 hours (during those 24 hours: I tried to find the cause myself without any luck, my hair went from brown to gray, I considered a couple of times to throw my pc out of the window and I contacted Microsoft to escalate the problem and provided them with log information and such) &#8230; News came from Microsoft that they where able to identify the cause of the problem and had a solution. Finally some good news.</p>
<p>The problem seemed to be that the patch tried to update the tfs_Configuration database but that it was unable to do so because that database was being mirrored. This caused TFS never to recover from servicing mode making it useless. unfortunately the installation wizard completed with success. First thing going through my mind was &#8230;</p>
<p><a href="http://frisoderidder.files.wordpress.com/2010/09/wtf.jpg"><img class="aligncenter size-medium wp-image-138" title="WTF" src="http://frisoderidder.files.wordpress.com/2010/09/wtf.jpg?w=270&#038;h=300" alt="wtf" width="270" height="300" /></a></p>
<p>The solution was simple.</p>
<ol>
<li> Remove the mirroring from the database.</li>
<li>Shut down any running TFS processes and then wait for 16 minutes or more (it seems somebody at Microsoft timed this).</li>
<li>Install the patch again.</li>
</ol>
<p>30 minutes later it was like nothing ever happened. And there was yet again a smile on my face.</p>
<p>Tip of the day:</p>
<p><strong>Always make sure, before installing a patch for TFS, none of the affected databases is being backed up nor mirrored.</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frisoderidder.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frisoderidder.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frisoderidder.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frisoderidder.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frisoderidder.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frisoderidder.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frisoderidder.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frisoderidder.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frisoderidder.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frisoderidder.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frisoderidder.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frisoderidder.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frisoderidder.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frisoderidder.wordpress.com/130/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=130&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frisoderidder.wordpress.com/2010/09/23/important-prerequisite-for-installing-a-patch-for-tfs-2o1o-if-you-dont-read-this-changes-are-you-are-going-to-die/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08f8c7c243392538b2d5bec4af69af3a?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">frisoderidder</media:title>
		</media:content>

		<media:content url="http://frisoderidder.files.wordpress.com/2010/09/servicingerror.png?w=300" medium="image">
			<media:title type="html">ServicingError</media:title>
		</media:content>

		<media:content url="http://frisoderidder.files.wordpress.com/2010/09/wtf.jpg?w=270" medium="image">
			<media:title type="html">WTF</media:title>
		</media:content>
	</item>
		<item>
		<title>Using MEF as a simple DI-container</title>
		<link>http://frisoderidder.wordpress.com/2010/08/15/using-mef-as-a-simple-di-container/</link>
		<comments>http://frisoderidder.wordpress.com/2010/08/15/using-mef-as-a-simple-di-container/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 18:00:14 +0000</pubDate>
		<dc:creator>frisoderidder</dc:creator>
				<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://frisoderidder.wordpress.com/?p=87</guid>
		<description><![CDATA[Lately I&#8217;ve been looking at MEF, more specifically at how I could use it as a simple DI-container. What I wanted to do was the following: Register the needed assemblies in the container Use the container as a factory from which I could request instances from certain types and that would resolve all the underlying [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=87&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been looking at <a href="http://mef.codeplex.com/">MEF</a>, more specifically at how I could use it as a simple DI-container. What I wanted to do was the following:</p>
<ol>
<li>Register the needed assemblies in the container</li>
<li>Use the container as a factory from which I could request instances from certain types and that would resolve all the underlying dependencies for me</li>
</ol>
<p>Seems it is not that hard to accomplish. Watch and learn&#8230;</p>
<p><pre class="brush: csharp;">

    public interface IUserRepository: IRepository
    {
        User Create(string userName, string password);
    }

    public interface IUserService
    {
        User Create(string userName, string password);
    }

    [Export(typeof(IUserService))]
    public class UserService: IUserService
    {
        private readonly IUserRepository _repository;

        [ImportingConstructor]
        public UserService(IUserRepository repository)
        {
            _repository = repository;
        }
        public User Create(string userName, string password)
        {
            return _repository.Create(userName, password);
        }
    }

        private void CreateContainer()
        {
            AggregateCatalog catalog = new AggregateCatalog();
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(IUserRepository).Assembly));
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(IUserService).Assembly));

            _container = new CompositionContainer(catalog);
            _container.ComposeParts(this);
        }
</pre></p>
<p>Two things are important here:</p>
<ol>
<li> The [ImportingConstructor] attribuut on the constructor of the UserService will tell MEF that it needs to resolve and inject the constructor parameters.</li>
<li>The [Export(typeof(IUserService))] will make the UserService class discoverable for MEF and more importantly for the problem at hand it will make it possible to get an instance of the UserService from the container.</li>
</ol>
<p>Now we can ask the container to give us an instance of a registered type that implements IUserService.</p>
<p><pre class="brush: csharp;">

        [TestMethod()]
        public void CreateTest()
        {
            var service = _container.GetExportedValue&lt;IUserService&gt;();

            service.Create(&quot;friso&quot;, &quot;C0mplexPwd&quot;);
        }

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frisoderidder.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frisoderidder.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frisoderidder.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frisoderidder.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frisoderidder.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frisoderidder.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frisoderidder.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frisoderidder.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frisoderidder.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frisoderidder.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frisoderidder.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frisoderidder.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frisoderidder.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frisoderidder.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=87&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frisoderidder.wordpress.com/2010/08/15/using-mef-as-a-simple-di-container/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08f8c7c243392538b2d5bec4af69af3a?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">frisoderidder</media:title>
		</media:content>
	</item>
		<item>
		<title>Material RealDolmen Brains Session: Design Patterns (part 2) online</title>
		<link>http://frisoderidder.wordpress.com/2010/07/28/material-realdolmen-brains-session-design-patterns-part-2-online/</link>
		<comments>http://frisoderidder.wordpress.com/2010/07/28/material-realdolmen-brains-session-design-patterns-part-2-online/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 11:14:02 +0000</pubDate>
		<dc:creator>frisoderidder</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://frisoderidder.wordpress.com/?p=81</guid>
		<description><![CDATA[The slide deck and code samples of the Design Patterns (part 2) brains session from 30/06/2010 can be downloaded from the RealDolmen portal. Note: only accessable for RealDolmen employees.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=81&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The slide deck and code samples of the Design Patterns (part 2) brains session from 30/06/2010 can be downloaded from the <a href="https://portal.realdolmen.com/sites/microsoft/squads/RealDolmen%20Brains%20Downloads/Forms/AllItems.aspx">RealDolmen portal.</a></p>
<p><em>Note: only accessable for RealDolmen employees.</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frisoderidder.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frisoderidder.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frisoderidder.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frisoderidder.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frisoderidder.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frisoderidder.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frisoderidder.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frisoderidder.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frisoderidder.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frisoderidder.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frisoderidder.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frisoderidder.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frisoderidder.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frisoderidder.wordpress.com/81/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=81&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frisoderidder.wordpress.com/2010/07/28/material-realdolmen-brains-session-design-patterns-part-2-online/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08f8c7c243392538b2d5bec4af69af3a?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">frisoderidder</media:title>
		</media:content>
	</item>
		<item>
		<title>Material RealDolmen Brains Session: Design Patterns (part 1) online</title>
		<link>http://frisoderidder.wordpress.com/2010/06/01/material-realdolmen-brains-session-design-patterns-part-1-online/</link>
		<comments>http://frisoderidder.wordpress.com/2010/06/01/material-realdolmen-brains-session-design-patterns-part-1-online/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 15:32:18 +0000</pubDate>
		<dc:creator>frisoderidder</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://frisoderidder.wordpress.com/?p=73</guid>
		<description><![CDATA[The slide deck and code of the Design Patterns ( part 1) brains session from 25/05/2010 can be downloaded from the realdolmen portal. Note: only accessable for RealDolmen employees.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=73&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The slide deck and code of the Design Patterns ( part 1) brains session from 25/05/2010 can be downloaded from the <a href="https://portal.realdolmen.com/sites/microsoft/squads/RealDolmen%20Brains%20Downloads/Forms/AllItems.aspx">realdolmen portal</a>.</p>
<p><em>Note: only accessable for RealDolmen employees.</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frisoderidder.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frisoderidder.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frisoderidder.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frisoderidder.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frisoderidder.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frisoderidder.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frisoderidder.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frisoderidder.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frisoderidder.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frisoderidder.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frisoderidder.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frisoderidder.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frisoderidder.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frisoderidder.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=73&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frisoderidder.wordpress.com/2010/06/01/material-realdolmen-brains-session-design-patterns-part-1-online/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08f8c7c243392538b2d5bec4af69af3a?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">frisoderidder</media:title>
		</media:content>
	</item>
		<item>
		<title>Using the Decorator design pattern to extend your classes behavior</title>
		<link>http://frisoderidder.wordpress.com/2010/05/24/using-the-decorator-design-pattern-to-extend-your%c2%a0classes%c2%a0behavior/</link>
		<comments>http://frisoderidder.wordpress.com/2010/05/24/using-the-decorator-design-pattern-to-extend-your%c2%a0classes%c2%a0behavior/#comments</comments>
		<pubDate>Mon, 24 May 2010 11:24:39 +0000</pubDate>
		<dc:creator>frisoderidder</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false">http://frisoderidder.wordpress.com/?p=13</guid>
		<description><![CDATA[&#8220;Favor object composition over class inheritance&#8221; is one of many software design principles out there . I won&#8217;t explain the meaning of the principle in this post, rather I would like to show you one of the ways it can be achieved. For a profound explanation of the principle I suggest you Google it or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=13&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8220;Favor object composition over class inheritance&#8221; is one of many software design principles out there . I won&#8217;t explain the meaning of the principle in this post, rather I would like to show you one of the ways it can be achieved. For a profound explanation of the principle I suggest you <a href="http://www.google.com">Google it</a> or read about it <a href="http://en.wikipedia.org/wiki/Design_Patterns">here</a>, <a href="http://blogs.msdn.com/steverowe/archive/2008/04/28/prefer-composition-over-inheritance.aspx">here</a> and <a href="http://www.artima.com/lejava/articles/designprinciples4.html">here</a>.</p>
<h2>The hypothetical car factory example</h2>
<p>At this point in time the car factory we&#8217;re working on sells two types of cars: the &#8220;Sport blaster 2000&#8243; and the &#8220;City cruiser 2000&#8243;. The class diagram is as follows:<br />
<a href="http://frisoderidder.files.wordpress.com/2010/05/initialclassdiagram.png"><img class="aligncenter size-medium wp-image-25" title="InitialClassDiagram" src="http://frisoderidder.files.wordpress.com/2010/05/initialclassdiagram.png?w=300&#038;h=165" alt="" width="300" height="165" /></a><br />
And the classes look like this:</p>
<p><pre class="brush: csharp;">
    public abstract class Car
    {
        public abstract string Name { get; set; }
        public abstract string GetOptions();
    }

    public class SportCar: Car
    {
        private string name = &quot;Sport blaster 2000&quot;;

        public override string Name
        {
            get{ return name;}
            set{ name = value;}
        }

        public override string GetOptions()
        {
            return string.Empty;
        }
    }

    public class CityCar: Car
    {
        private string name = &quot;City cruiser 2000&quot;;

        public override string Name
        {
            get {return name; }
            set{name = value;}
        }

        public override string GetOptions()
        {
            return string.Empty;
        }
    }
</pre></p>
<p>As you can see the Car class has a method &#8220;GetOptions&#8221; that will return the options for a specific car instance. For starters we want a gps, cruise control and tv option. We also want to keep in mind that in the future new options can be added and others could be removed.</p>
<h2>Solution #1</h2>
<p>Let&#8217;s add a boolean for each option to our base class and give the &#8220;GetOptions&#8221; method a base implementation. It would look something like this:</p>
<p><pre class="brush: csharp;">
    public abstract class Car
    {
        public abstract string Name { get; set; }

        public bool Gps{get;set;}
        public bool Tv{get;set;}
        public bool CruiseControl{get;set;}

        public virtual string GetOptions()
        {
            var options = string.Empty;

            if(Gps)options += &quot;Gps, &quot;;
            if(Tv)options += &quot;Tv, &quot;;
            if(CruiseControl)options += &quot;Cruise control, &quot;;

            return options;
        }
    }
</pre></p>
<p>The problem with this approach is that it will quickly become unmaintainable. Every time a new option becomes available or one gets removed we will have to change our Car base class and every subclass that uses these options, this could also have an effect on the consumers of those classes. Also what if we want to add multiple tv&#8217;s to one Car? Or what if a Tv can&#8217;t be added to all our models than we would have to implement some custom logic in those subclasses. Because the &#8220;GetOptions&#8221; method is implemented in the Car class, changing this method will have an impact on its subclasses, this change could potentially have unwanted effects for one of those subclasses.</p>
<h2>Solution #2</h2>
<p>Create a subclass for every possible combination. I&#8217;m not going to build this example but by applying some simple math (2^3 *2) you&#8217;ll find out that this approach would need 16 classes already,  just for the current situation, a real class explosion. Again a maintenance nightmare.</p>
<p>What we would really like is have the ability to extend the Car class (adding new options) without having to touch the Car class itself. I have a feeling that Solution 3 will give us the answer we are searching for.</p>
<h2>Solution #3</h2>
<p>Meet the Decorator pattern. For a profound theoretical explanation of this pattern look <a href="http://en.wikipedia.org/wiki/Decorator_pattern">here</a> and <a href="http://www.codeproject.com/KB/architecture/Decorator_Design_Pattern.aspx">here</a>. In a nutshell a decorator extends a class its functionality by wrapping an instance of that class in it and overriding its behavior. Let&#8217;s look at our car decorator base class.</p>
<p><pre class="brush: csharp;">
    public abstract class CarDecorator: Car
    {
        protected readonly Car car;

        protected CarDecorator(Car car)
        {
            this.car = car;
        }

        public override string Name
        {
            get {return car.Name; }
            set {car.Name = value;}
        }
    }
</pre></p>
<p>Two things to point out here.</p>
<p>First: the CarDecorator inherits Car, meaning that it will behave as a Car. If you stick, and actually you should, to the design principle that states that you should always program against an interface (an abstract class or a .Net interface) instead of a concrete implementation you will be able to switch an implementation of a Car by an implementation of a CarDecorator without your consumers noticing it.</p>
<p>Secondly: the CarDecorator receives an instance of a car in its constructor (this could be a SportCar or a CityCar or even another CarDecorator) and uses it to implements its Name property.</p>
<p>Next we are going to implement our concrete CarDecorators.</p>
<p><pre class="brush: csharp;">
    public class GpsDecorator: CarDecorator
    {
        public GpsDecorator(Car car):base(car)
        {
        }

        public override string GetOptions()
        {
            return car.GetOptions() + &quot;Gps, &quot;;
        }
    }

    public class TvDecorator: CarDecorator
    {
        public TvDecorator(Car car)
            : base(car)
        {
        }

        public override string GetOptions()
        {
            return car.GetOptions() + &quot;Tv, &quot;;
        }
    }
</pre></p>
<p>Both decorators overwrite the &#8220;GetOptions&#8221; method by first calling the &#8220;car.GetOptions&#8221; method and then adding their own option.<br />
Let&#8217;s see at the result of our little test application.</p>
<p><pre class="brush: csharp;">
	class Program
	{
		static void Main(string[] args)
		{
            Car sportCar = new SportCar();
            Car cityCar = new CityCar();

            Console.WriteLine(&quot;Cars with no decorations\n&quot;);
            Console.WriteLine(&quot;Sport car options: &quot;+ sportCar.GetOptions() + &quot;\n&quot;);
            Console.WriteLine(&quot;City car options: &quot; + cityCar.GetOptions() + &quot;\n&quot;);

            sportCar = new CruiseControlDecorator(sportCar);
            cityCar = new TvDecorator(new GpsDecorator(cityCar));

            Console.WriteLine(&quot;\n\nCars with decorations\n&quot;);
            Console.WriteLine(&quot;Sport car options: &quot; + sportCar.GetOptions() + &quot;\n&quot;);
            Console.WriteLine(&quot;City car options: &quot; + cityCar.GetOptions() + &quot;\n&quot;);

            Console.ReadLine();
		}
	}
</pre></p>
<p>And when we run this:</p>
<p><a href="http://frisoderidder.files.wordpress.com/2010/05/programresult1.png"><img class="aligncenter size-medium wp-image-56" title="DecoratedCarFactory_ProgramResult" src="http://frisoderidder.files.wordpress.com/2010/05/programresult1.png?w=300&#038;h=151" alt="" width="300" height="151" /></a></p>
<p>The class diagram now looks like this:</p>
<p><a href="http://frisoderidder.files.wordpress.com/2010/05/resultclassdiagram.png"><img src="http://frisoderidder.files.wordpress.com/2010/05/resultclassdiagram.png?w=300&#038;h=145" alt="" title="DecoratedCarFactory_ResultClassDiagram" width="300" height="145" class="aligncenter size-medium wp-image-61" /></a></p>
<h2>Summary</h2>
<p>I was able to add functionality to my car implementations without touching those classes and even better, the consumers of my car classes wouldn&#8217;t even notice because they are still programming against an instance of Car. In the future when options are added or removed this will have no impact on my Car classes themselves which is a big advantage regarding to maintenance and testing.</p>
<p>I hope I was able to convince you guys that instead of creating large inheritance trees or extending base classes to the limit the Decorator pattern is a nice alternative to be considered next time you face a similar problem.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frisoderidder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frisoderidder.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frisoderidder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frisoderidder.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frisoderidder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frisoderidder.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frisoderidder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frisoderidder.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frisoderidder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frisoderidder.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frisoderidder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frisoderidder.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frisoderidder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frisoderidder.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=13&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frisoderidder.wordpress.com/2010/05/24/using-the-decorator-design-pattern-to-extend-your%c2%a0classes%c2%a0behavior/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08f8c7c243392538b2d5bec4af69af3a?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">frisoderidder</media:title>
		</media:content>

		<media:content url="http://frisoderidder.files.wordpress.com/2010/05/initialclassdiagram.png?w=300" medium="image">
			<media:title type="html">InitialClassDiagram</media:title>
		</media:content>

		<media:content url="http://frisoderidder.files.wordpress.com/2010/05/programresult1.png?w=300" medium="image">
			<media:title type="html">DecoratedCarFactory_ProgramResult</media:title>
		</media:content>

		<media:content url="http://frisoderidder.files.wordpress.com/2010/05/resultclassdiagram.png?w=300" medium="image">
			<media:title type="html">DecoratedCarFactory_ResultClassDiagram</media:title>
		</media:content>
	</item>
		<item>
		<title>Hello WordPress</title>
		<link>http://frisoderidder.wordpress.com/2010/05/22/hello-world/</link>
		<comments>http://frisoderidder.wordpress.com/2010/05/22/hello-world/#comments</comments>
		<pubDate>Sat, 22 May 2010 08:13:46 +0000</pubDate>
		<dc:creator>frisoderidder</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://frisoderidder.wordpress.com/?p=1</guid>
		<description><![CDATA[Finally I&#8217;ve got myself to sit down for an hour and set up my own free WordPress blog. I&#8217;m a big .Net and programming in general enthusiast so you will find me blogging about everything that interests me related to those topics. While awaiting my first &#8220;real&#8221; blog post, you can already check out my [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=1&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Finally I&#8217;ve got myself to sit down for an hour and set up my own free WordPress blog.</p>
<p>I&#8217;m a big .Net and programming in general enthusiast so you will find me blogging about everything that interests me related to those topics.</p>
<p>While awaiting my first &#8220;real&#8221; blog post, you can already check out my about page to learn something more about this blogger.</p>
<p>I hope you will enjoy reading my blog and maybe even learn something from it.</p>
<p>Cheers</p>
<p>Friso</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frisoderidder.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frisoderidder.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frisoderidder.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frisoderidder.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frisoderidder.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frisoderidder.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frisoderidder.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frisoderidder.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frisoderidder.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frisoderidder.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frisoderidder.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frisoderidder.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frisoderidder.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frisoderidder.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frisoderidder.wordpress.com&amp;blog=13809974&amp;post=1&amp;subd=frisoderidder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frisoderidder.wordpress.com/2010/05/22/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08f8c7c243392538b2d5bec4af69af3a?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">frisoderidder</media:title>
		</media:content>
	</item>
	</channel>
</rss>
