<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>Quickduck</title>
	<link>http://quickduck.com/blog</link>
	<description>Straight from the mind of geniuseseses....</description>
	<pubDate>Thu, 13 Nov 2008 22:47:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Writing clean, usuable CSS</title>
		<link>http://quickduck.com/blog/2008/11/13/writing-clean-usuable-css/</link>
		<comments>http://quickduck.com/blog/2008/11/13/writing-clean-usuable-css/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 22:47:45 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[Development]]></category>

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

		<guid isPermaLink="false">http://quickduck.com/blog/2008/11/13/writing-clean-usuable-css/</guid>
		<description><![CDATA[This article demonstrates 21 techniques you can employ to write usable CSS.
]]></description>
			<content:encoded><![CDATA[<p>This <a href="http://www.apaddedcell.com/21-ways-streamline-your-css">article</a> demonstrates 21 techniques you can employ to write usable CSS.</p>
]]></content:encoded>
			<wfw:commentRss>http://quickduck.com/blog/2008/11/13/writing-clean-usuable-css/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Creating Custom Exception Types</title>
		<link>http://quickduck.com/blog/2008/11/10/creating-custom-exception-types/</link>
		<comments>http://quickduck.com/blog/2008/11/10/creating-custom-exception-types/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 01:20:27 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[.Net]]></category>

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

		<guid isPermaLink="false">http://quickduck.com/blog/2008/11/10/creating-custom-exception-types/</guid>
		<description><![CDATA[One of the things that pops up over and over in project development is the issue of when to create Custom Exceptions. 
To come to any form of conclusion it’s necessary to understand the reason why you might create your own Exception class.
1.	To allow typesafe error detection and act appropriately.
2.	To add context specific data.
3.	There’s no [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things that pops up over and over in project development is the issue of when to create Custom Exceptions. </p>
<p>To come to any form of conclusion it’s necessary to understand the reason why you might create your own Exception class.</p>
<p>1.	To allow typesafe error detection and act appropriately.<br />
2.	To add context specific data.<br />
3.	There’s no existing framework exception that signifies the error.</p>
<p><strong>1.	To allow typesafe error detection.</strong></p>
<p>Creating a customized exception allows the receiver to act upon a specific error. Using this approach the receiver is forced to detect that specific error to perform any useful action.<br />
Examples where creating a custom exception for this scenario to make sense include;</p>
<p>- situations where you may need to prompt a user to correct a problem (e.g. disk full exception)<br />
  or<br />
- where you need to log specific exceptions.</p>
<p><strong>2.	To add context specific data.</strong></p>
<p>By adding more context to an exception, the receiver of the exception can use this information to help track down and recover from the error.</p>
<p>An example; say the validation rules for an object instance fail, by attaching the validation rules to the exception the receiver may use them to display appropriate error messages on screen to help recover from the error.</p>
<p>E.g.</p>
<pre><code>
public class ValidationException : Exception {

  public ValidationException(ValidationResults results) : base(results.ToString())
  {
Results = results;
  }

  public ValidationResults Results {get;set;}
} 

public class ValidationResults : IEnumerable&lt;KeyValuePair&lt;string,string&gt;&gt; {

  public IEnumerator&lt;KeyValuePair&lt;string, string&gt;&gt; GetEnumerator() {
    ...
  }

  IEnumerator IEnumerable.GetEnumerator() {
    return GetEnumerator();
  }
}

Usage:

try {
  ...
  ...
} catch (ValidationException ve) {
  foreach (var result in ve.Results) {
    Console.WriteLine("Error:" + result.Key + " : " + result.Value);
  }
}
</code</pre>
<p>Alternately, the System.Exception class contains a Data Dictionary property that can be used to attach context without having to create your own customized exception class:</p>
<p>E.g.</p>
<pre><code>
var exception = new InvalidOperationException("ValidationException"); 

var validationResults = new Dictionary&lt;string, string&gt;();
validationResults["Name"] = "The Name value is too long.";
validationResults["Postcode"] = "The Postcode is invalid.";
exception.Data.Add("ValidationResults", validationResults);

throw exception;
</code</pre>
<p>The lack of type safety in the Data dictionary may be off-putting but using extension methods you can add some type safety.</p>
<pre><code>
public static IDictionary&lt;string, string&gt; GetValidationResults(this InvalidOperationException ioe)
{
  if (ioe.Data.Contains("ValidationResults"))
  {
    return ioe.Data["ValidationResults"] as Dictionary&lt;string,string&gt;;
  }
  return new Dictionary&lt;string, string&gt;();
}

public static string GetValidationMessage(this InvalidOperationException ioe, string key)
{
  if (ioe.Data.Contains("ValidationResults"))
  {
    return ((IDictionary&lt;string, string&gt;) ioe.Data["ValidationResults"])[key];
  }
  return null;
}
</code</pre>
<p>I find that using the Data dictionary approach may save you the benefit of creating a Custom Exception but at the expense of more verbose and un-intuitive code.</p>
<p><strong>3.	There’s no existing framework exception that signifies the error.</strong></p>
<p>The detail level to which you can specify an exception type is infinite. When it comes down to it there are few framework exception types that are valid for most scenarios:</p>
<p>Input value causes exception; throw one of </p>
<p>System.ArgumentException<br />
System.ArgumentNullException<br />
   System.ArgumentOutOfRangeException</p>
<p>For all other errors a good default option is to use the System.InvalidOperationException.</p>
<p><strong>Conclusion:</strong></p>
<p>To sum up, think carefully about the specific scenario that is being addressed when writing exception logic, follow this checklist to help in your decision making.</p>
<p><strong>Is there a need to act upon the specific exception and find a way to recover from it?</strong></p>
<p>Yes -&gt; Consider creating a generic custom exception.<br />
For example create an exception named DuplicateEntityException rather than JobRateAlreadyExistsException.</p>
<p>No -&gt; throw an existing exception type.</p>
<p><strong>Do you need to log a specific error scenario?</strong></p>
<p>Yes -&gt; Consider creating a generic custom exception.<br />
No -&gt; throw an existing exception type.</p>
<p><strong>Do you need extra information in the exception to respond effectively?</strong></p>
<p>Yes -&gt; Determine whether creating a custom exception with typesafe data members is more intuitive than using the Data dictionary on the System.Exception class.<br />
No -&gt; throw an existing exception type.</p>
<p>For all other scenarios default to throwing an existing exception type.</p>
<p>What are your thoughts and experiences on this issue? </p>
]]></content:encoded>
			<wfw:commentRss>http://quickduck.com/blog/2008/11/10/creating-custom-exception-types/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Enterprise Library Walkthrough</title>
		<link>http://quickduck.com/blog/2008/11/07/enterprise-library-walkthrough/</link>
		<comments>http://quickduck.com/blog/2008/11/07/enterprise-library-walkthrough/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 06:17:57 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[.Net]]></category>

		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://quickduck.com/blog/2008/11/07/enterprise-library-walkthrough/</guid>
		<description><![CDATA[What is Enterprise Library?
Ent.Lib 4.1 - http://msdn.microsoft.com/en-us/library/dd203099.aspx
The Microsoft Enterprise Library is a collection of reusable software components (application blocks) designed to assist software developers with common enterprise development cross-cutting concerns (such as logging, validation, data access, exception handling, and many others).

The application blocks aim to encapsulate proven best-practice for enterprise .net development. 
In total there [...]]]></description>
			<content:encoded><![CDATA[<h2>What is Enterprise Library?</h2>
<p><a href="http://msdn.microsoft.com/en-us/library/dd203099.aspx">Ent.Lib 4.1 - http://msdn.microsoft.com/en-us/library/dd203099.aspx</a></p>
<p><em>The Microsoft Enterprise Library is a collection of reusable software components (application blocks) designed to assist software developers with common enterprise development cross-cutting concerns (such as logging, validation, data access, exception handling, and many others).<br />
</em></p>
<p>The application blocks aim to encapsulate proven best-practice for enterprise .net development. </p>
<p>In total there are over 9 application blocks:</p>
<ul>
<li>Caching</li>
<li>Cryptography</li>
<li>Data Access
</li>
<li>Exception Handling
</li>
<li>Logging</li>
<li>Policy Injection</li>
<li>Security </li>
<li>Unity - Dependency Injection (IoC) container</li>
<li>Validation</li>
</ul>
<p>This article will address the Exception, Logging, Validation and Unity application block.  The new Unity Application block encapsulates the Policy Injection block and as such will not be addressed in this article along with the Caching, Cryptography and Security blocks.</p>
<p><strong>Download Ent. Library 4.1 here:</strong><br />
<a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=1643758B-2986-47F7-B529-3E41584B6CE5&#038;displaylang=en">http://www.microsoft.com/downloads/details.aspx?FamilyId=1643758B-2986-47F7-B529-3E41584B6CE5&#038;displaylang=en</a></p>
<h2 style="color:red;">Important:</h2>
<p>This article is just a rehash of information easily found in the Ent.Library documentation and online websites. To get a comprehensive understanding of how the blocks work download the <a href='http://quickduck.com/blog/wp-content/uploads/2008/11/enterpriselibrarywalkthrough.zip' title='enterpriselibrarywalkthrough.zip'>Sample Code</a> I&#8217;ve created here.</p>
<p>Alternately, for further demonstrations on how these blocks work, load up the included QuickStart tutorials included with the Ent. Lib download.</p>
<p><strong>Note:</strong><br />
The solution is works with VS 2008 Team System. It utilizes the seperate Unity Application block but works with Ent. Library 3.1 for all other App. Blocks due to 3rd party software we use that has a dependency on Ent. Lib 3.1.</p>
<p>To migrate to Ent. Lib 4.1 just change all references for 3.1 app blocks to 4.1 app blocks.<br />
You will also be able to remove out the the ApplicationCode/CallHandlers/*.cs files and use the 4.1 PolicyInjection CallHandlers.</p>
<p><strong>NOTE: Be sure to read the rest of this article by clicking the link below.</strong></p>
<p> <a href="http://quickduck.com/blog/2008/11/07/enterprise-library-walkthrough/#more-79" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://quickduck.com/blog/2008/11/07/enterprise-library-walkthrough/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Cohesion and Coupling</title>
		<link>http://quickduck.com/blog/2008/11/04/cohesion-and-coupling/</link>
		<comments>http://quickduck.com/blog/2008/11/04/cohesion-and-coupling/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 22:36:07 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://quickduck.com/blog/2008/11/04/cohesion-and-coupling/</guid>
		<description><![CDATA[Remember taking Software Design 101 at University and hearing the terms Cohesion and Coupling being thrown about but were too hungover to pay attention?
Well this article by Jeremy Miller is an excellent introduction (or re-introduction) to Cohesion and Coupling - two terms I believe you need a strong comprehension of to design good software.
]]></description>
			<content:encoded><![CDATA[<p>Remember taking Software Design 101 at University and hearing the terms Cohesion and Coupling being thrown about but were too hungover to pay attention?</p>
<p>Well this <a href="http://msdn.microsoft.com/en-us/magazine/cc947917.aspx">article</a> by Jeremy Miller is an excellent introduction (or re-introduction) to Cohesion and Coupling - two terms I believe you need a strong comprehension of to design good software.</p>
]]></content:encoded>
			<wfw:commentRss>http://quickduck.com/blog/2008/11/04/cohesion-and-coupling/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reader challenge!</title>
		<link>http://quickduck.com/blog/2008/11/03/reader-challenge/</link>
		<comments>http://quickduck.com/blog/2008/11/03/reader-challenge/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 17:09:02 +0000</pubDate>
		<dc:creator>Gerrod</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[Daily Question]]></category>

		<guid isPermaLink="false">http://quickduck.com/blog/2008/11/03/reader-challenge/</guid>
		<description><![CDATA[It&#8217;s been a while since we&#8217;ve had a reader question, so here&#8217;s one for you all. It&#8217;s not that I can&#8217;t solve this problem; it&#8217;s more that I&#8217;m wondering if there&#8217;s a more elegant solution.
The Problem: Given two dates, what&#8217;s the easiest way of determining if they fall in the same week?
Please submit your answers [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since we&#8217;ve had a reader question, so here&#8217;s one for you all. It&#8217;s not that I <i>can&#8217;t</i> solve this problem; it&#8217;s more that I&#8217;m wondering if there&#8217;s a more elegant solution.</p>
<p><b>The Problem:</b> Given two dates, what&#8217;s the easiest way of determining if they fall in the same week?</p>
<p>Please submit your answers as a comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://quickduck.com/blog/2008/11/03/reader-challenge/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Flagged Enums</title>
		<link>http://quickduck.com/blog/2008/11/02/using-flagged-enums/</link>
		<comments>http://quickduck.com/blog/2008/11/02/using-flagged-enums/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 23:28:11 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[.Net]]></category>

		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://quickduck.com/blog/2008/11/02/using-flagged-enums/</guid>
		<description><![CDATA[Have you ever written or come across code where you have a series of boolean values that determine whether or not certain actions are allowed?
Example:

public class WorkDays
{
  public bool Sunday { get; set; }
  public bool Monday { get; set; }
  public bool Tuesday { get; set; }
  public bool Wednesday [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever written or come across code where you have a series of boolean values that determine whether or not certain actions are allowed?</p>
<p>Example:</p>
<pre><code>
public class WorkDays
{
  public bool Sunday { get; set; }
  public bool Monday { get; set; }
  public bool Tuesday { get; set; }
  public bool Wednesday { get; set; }
  public bool Thursday { get; set; }
  public bool Friday { get; set; }
  public bool Saturday { get; set; }

  public bool Weekdays { get { return Monday &#038;&#038; Tuesday &#038;&#038; Wednesday &#038;&#038; Thursday &#038;& Friday; } }
  public bool Weekends { get { return Sunday &#038;& Saturday; } }

  public int NumberOfDaysWorked
        {
            get
            {
                int numberOfDaysWorked = 0;

                if (CanWorkMonday) numberOfDaysWorked++;
                if (CanWorkTuesday) numberOfDaysWorked++;
                if (CanWorkWednesday) numberOfDaysWorked++;
                if (CanWorkThursday) numberOfDaysWorked++;
                if (CanWorkFriday) numberOfDaysWorked++;
                if (CanWorkSaturday) numberOfDaysWorked++;
                if (CanWorkSunday) numberOfDaysWorked++;

                return numberOfDaysWorked;
            }
        }
}

</code></pre>
<p>There&#8217;s a more elegant approach that is utilized through the standard .net framework that we too can mimic.</p>
<p>This scenario is a perfect candidate for using a flagged enum and the power of bit operations. </p>
<pre><code>

    [Flags]
    public enum Days
    {
        None = 0,
        Sunday = 1,
        Monday = 2,
        Tuesday = 4,
        Wednesday = 8,
        Thursday = 16,
        Friday = 32,
        Saturday = 64,
        MondayToFriday = Monday | Tuesday | Wednesday | Thursday | Friday,
        Weekend = Saturday | Sunday,
        All = MondayToFriday | Weekend,
    }

    public class WorkDays
    {
        public Days DaysWorked { get; set; }

        /// &lt;summary&gt;
        /// Get the Number of Days worked.
        /// NOTE: Uses bitwise and operation.
        /// &lt;/summary&gt;
        public int NumberOfDaysWorked
        {
            get
            {
                Days days = DaysWorked;
                int numberOfDaysWorked = 0;
                for (; days != 0; numberOfDaysWorked++)
                {
                    days &#038;= days - 1; // clear the least significant bit set
                }
                return numberOfDaysWorked;
            }
        }
    }

</code></pre>
<p>By defining an enum with each successive value a power of 2 greater (i.e. binary) you can then use the bitwise or (|) and bitwise (&#038;) operations to group and determine which values are selected.</p>
<pre><code>
    [TestClass]
    public class ExampleTestClass
    {
        [TestMethod]
        public void Test()
        {
            var mondayToFriday = new WorkDays { DaysWorked = Days.MondayToFriday };
            Assert.IsFalse(Days.Sunday.In(mondayToFriday.DaysWorked));
            Assert.IsFalse(Days.Saturday.In(mondayToFriday.DaysWorked));
            Assert.IsTrue(Days.Wednesday.In(mondayToFriday.DaysWorked));
            Assert.AreEqual(5, mondayToFriday.NumberOfDaysWorked);

            var monday = new WorkDays { DaysWorked = Days.Monday };
            Assert.IsFalse(Days.Sunday.In(monday.DaysWorked));
            Assert.IsTrue(Days.Monday.In(monday.DaysWorked));
            Assert.AreEqual(1, monday.NumberOfDaysWorked);

            var mondayAndWednesday = new WorkDays { DaysWorked = Days.Monday | Days.Wednesday };
            Assert.IsFalse(Days.Tuesday.In(mondayAndWednesday.DaysWorked));
            Assert.IsTrue(Days.Monday.In(mondayAndWednesday.DaysWorked));
            Assert.IsTrue(Days.Wednesday.In(mondayAndWednesday.DaysWorked));
            Assert.AreEqual(2, mondayToFriday.NumberOfDaysWorked);

            var weekend = new WorkDays { DaysWorked = Days.Weekend};
            Assert.IsTrue(Days.Saturday.In(weekend.DaysWorked));
            Assert.IsTrue(Days.Sunday.In(weekend.DaysWorked));
            Assert.IsFalse(Days.MondayToFriday.In(weekend.DaysWorked));
            Assert.AreEqual(2, weekend.NumberOfDaysWorked);
        }
    }

    public static class Extensions
    {
        /// &lt;summary&gt;
        /// Is the specified enumeration value within the range of Enum values?
        /// &lt;/summary&gt;
        /// &lt;param name="value"&gt;the enum value to look for in the range&lt;/param&gt;
        /// &lt;param name="range"&gt;the range of enum values (eg. bitwise OR'd values)&lt;/param&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public static bool In(this Enum value, Enum range)
        {
            var valueNumber = (int) Enum.Parse(value.GetType(), value.ToString());
            var rangeNumber = (int) Enum.Parse(range.GetType(), range.ToString());
            return (valueNumber &#038; rangeNumber) == valueNumber;
        }
    }
</code></pre>
<p>For further information check out the following resources:</p>
<p>If you’re gotten a bit rusty on your bitwise operations:<br />
<a href="http://en.wikipedia.org/wiki/Bitwise_operation">http://en.wikipedia.org/wiki/Bitwise_operation</a></p>
<p>Flagged Enum:<br />
<a href="http://weblogs.asp.net/wim/archive/2004/04/07/109095.aspx">http://weblogs.asp.net/wim/archive/2004/04/07/109095.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://quickduck.com/blog/2008/11/02/using-flagged-enums/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Visual Studio 2008 - Shortcut Keys for running Unit Tests</title>
		<link>http://quickduck.com/blog/2008/10/30/visual-studio-2008-shortcut-keys-for-running-unit-tests/</link>
		<comments>http://quickduck.com/blog/2008/10/30/visual-studio-2008-shortcut-keys-for-running-unit-tests/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 23:41:25 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[.Net]]></category>

		<category><![CDATA[C#]]></category>

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

		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://quickduck.com/blog/2008/10/30/visual-studio-2008-shortcut-keys-for-running-unit-tests/</guid>
		<description><![CDATA[Short Cut Keys to Run Tests: 
•         Ctl R, T: Run Tests in Current context (namespace, class, and method – ie. Based on where your cursor is within a file it determines the tests to run)
•         Ctl R, C: [...]]]></description>
			<content:encoded><![CDATA[<p>Short Cut Keys to Run Tests: </p>
<p>•         Ctl R, T: Run Tests in Current context (namespace, class, and method – ie. Based on where your cursor is within a file it determines the tests to run)<br />
•         Ctl R, C: Run Tests in Current Test Class<br />
•         Ctl R, N: Run Tests in Current Namespace<br />
•         Ctl R, S: Run All Tests in Solution<br />
•         Ctl R, D: Run the Tests in the Last Test Run<br />
•         Ctl R, F: Run the Failed Tests of the Last Test Run</p>
]]></content:encoded>
			<wfw:commentRss>http://quickduck.com/blog/2008/10/30/visual-studio-2008-shortcut-keys-for-running-unit-tests/feed/</wfw:commentRss>
		</item>
		<item>
		<title>I&#8217;m back</title>
		<link>http://quickduck.com/blog/2008/10/30/im-back/</link>
		<comments>http://quickduck.com/blog/2008/10/30/im-back/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 07:06:02 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[.Net]]></category>

		<category><![CDATA[Asp.Net]]></category>

		<category><![CDATA[C#]]></category>

		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://quickduck.com/blog/2008/10/30/im-back/</guid>
		<description><![CDATA[After having 9 months off from doing .net (travelling, bumming and then a 3 month contract role as an architect in a coldfusion shop) I finally got myself a role doing what I love doing best - playing with .net and c#.
In the last 4 weeks I&#8217;ve been researching and prototyping apps that use

.net 3.5
ado.net [...]]]></description>
			<content:encoded><![CDATA[<p>After having 9 months off from doing .net (travelling, bumming and then a 3 month contract role as an architect in a coldfusion shop) I finally got myself a role doing what I love doing best - playing with .net and c#.</p>
<p>In the last 4 weeks I&#8217;ve been researching and prototyping apps that use</p>
<ul>
<li>.net 3.5</li>
<li><a href="http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework">ado.net entity framework</a></li>
<li><a href="http://msdn.microsoft.com/en-us/data/bb931106.aspx">ado.net data services</a> - including .net, ajax and silverlight client libraries</li>
<li><a href="http://silverlight.net">Silverlight 2.0</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms364077(VS.80).aspx">Visual Studio for Software Testers - Web Testing</a></li>
</ul>
<p>It&#8217;s been awesome to have the time and resources to touch across all of these technologies to enjoy their benefits and to loath the limitations.</p>
<p>All in all I reckon all of the technologies are a great addition to the .net stack and look forward to seeing them mature with each new release.</p>
<p>I look forward to documenting my findings as I find time to re-work them into don&#8217;t-give-away-IP examples.</p>
]]></content:encoded>
			<wfw:commentRss>http://quickduck.com/blog/2008/10/30/im-back/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Running VS Unit Tests stops IIS</title>
		<link>http://quickduck.com/blog/2008/10/24/running-vs-unit-tests-stops-iis/</link>
		<comments>http://quickduck.com/blog/2008/10/24/running-vs-unit-tests-stops-iis/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 01:32:05 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[.Net]]></category>

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

		<guid isPermaLink="false">http://quickduck.com/blog/2008/10/24/running-vs-unit-tests-stops-iis/</guid>
		<description><![CDATA[We recently ran into this problem where we discovered that running our VS unit tests was killing IIS.
As with all problems, I like to break things down to the simplest scenario I can find and as such created a brand new unit test that did nothing to see if that still caused the problem - [...]]]></description>
			<content:encoded><![CDATA[<p>We recently ran into this problem where we discovered that running our VS unit tests was killing IIS.</p>
<p>As with all problems, I like to break things down to the simplest scenario I can find and as such created a brand new unit test that did nothing to see if that still caused the problem - it did.</p>
<p>So knowing that it had nothing to do with any code that was web dependent I knew to start looking elsewhere. </p>
<p>Turns out the problem is caused by enabling code coverage on projects that are dependent on IIS - e.g. a web project.</p>
<p><img src='http://quickduck.com/blog/wp-content/uploads/2008/10/codecoverage.jpg' alt='Visual Studio Code Coverage' width="500" /></p>
<p>The simple solution is to disable code coverage on the problem-causing project <strong>OR</strong> alternately remove the dependency on IIS by modifying it to  use the in-built Cassini web server.</p>
]]></content:encoded>
			<wfw:commentRss>http://quickduck.com/blog/2008/10/24/running-vs-unit-tests-stops-iis/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Enums for constant values</title>
		<link>http://quickduck.com/blog/2008/10/13/using-enums-for-constant-values/</link>
		<comments>http://quickduck.com/blog/2008/10/13/using-enums-for-constant-values/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 04:10:40 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://quickduck.com/blog/2008/10/13/using-enums-for-constant-values/</guid>
		<description><![CDATA[Have you ever found yourself using c# const values to remove the risks associated with using copies of string literals throughout your code base?
Example:


public static class VehicleTypesConsts {
  public const string Car = "Car";
  public const string Motorbike = "Motorbike";
  public const string Truck = "Truck";
}


In a situation like this it&#8217;s quite [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever found yourself using c# const values to remove the risks associated with using copies of string literals throughout your code base?</p>
<p>Example:</p>
<pre><code>

public static class VehicleTypesConsts {
  public const string Car = "Car";
  public const string Motorbike = "Motorbike";
  public const string Truck = "Truck";
}

</code></pre>
<p>In a situation like this it&#8217;s quite easy to replace these const values with a C# enum and use the System.Enum.GetName static method to return Enum properties name.</p>
<pre><code>

public enum VehicleTypesEnum {
  Car,
  Motorbike,
  Truck,
}

</code></pre>
<p>Calling </p>
<pre><code>
Enum.GetName(typeof(VehicleTypesEnum), VehicleTypesEnum.Car)
</code></pre>
<p>will return the string value &#8220;Car&#8221;.</p>
<p>Looking at this syntax you could be forgiven for thinking why bother? It&#8217;s too much hassle and looks puss. </p>
<p>Well using C# 3.0 extension methods you can provide a convenience method to all Enums to return the enum string representation.</p>
<pre><code>

public static class EnumExtensions {
  static public string GetName(this Enum enumeration) {
    return Enum.GetName(enumeration.GetType(), enumeration);
  }
}

</code></pre>
<p>Now you can just write:</p>
<pre><code>
VehicleTypesEnum.Car.GetName()
</code></pre>
<p>and it will return the string &#8220;Car&#8221;.</p>
<p>The following test method shows illustrates the varying ways to achieve the same result:</p>
<pre><code>

        [TestMethod]
        public void Test()
        {
            string expected = "Car";
            Assert.AreEqual(expected, VehicleTypesConsts.Car);
            Assert.AreEqual(expected, Enum.GetName(typeof(VehicleTypesEnum), VehicleTypesEnum.Car));
            Assert.AreEqual(expected, VehicleTypesEnum.Car.GetName());
        }

</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://quickduck.com/blog/2008/10/13/using-enums-for-constant-values/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
