<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Architecture</title>
        <link>http://geekswithblogs.net/btudor/category/9513.aspx</link>
        <description>Architecture</description>
        <language>en-US</language>
        <copyright>Bill Tudor</copyright>
        <managingEditor>btudor@nycap.rr.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>The Joel Test for 2010</title>
            <link>http://geekswithblogs.net/btudor/archive/2010/01/04/137329.aspx</link>
            <description>&lt;p&gt;Back in June, I posted my own version of the &lt;a href="http://www.joelonsoftware.com/articles/fog0000000043.html"&gt;Joel Test&lt;/a&gt; – updated for 2010. [&lt;a href="http://geekswithblogs.net/btudor/archive/2009/06/16/132842.aspx"&gt;See Here&lt;/a&gt;.]&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;p&gt;Do you have a change management system?&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Can everyone make a build in one step?&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Do your daily builds include automated tests?&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Is work item tracking integrated with source control?&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Do you fix bugs &lt;em&gt;and&lt;/em&gt; write new code?&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Do you track progress and manage change?&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Do you have a requirements management system?&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Do programmers have quiet working conditions and teaming rooms?&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Do you use the best tools money can buy?&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Are your testers involved in requirements management?&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Do new candidates review code during their interview?&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Do you do hallway usability testing?&lt;/p&gt;   &lt;/li&gt; &lt;/ol&gt; &lt;img src="http://geekswithblogs.net/btudor/aggbug/137329.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bill Tudor</dc:creator>
            <guid>http://geekswithblogs.net/btudor/archive/2010/01/04/137329.aspx</guid>
            <pubDate>Mon, 04 Jan 2010 10:52:07 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/btudor/comments/137329.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/btudor/archive/2010/01/04/137329.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/btudor/comments/commentRss/137329.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/btudor/services/trackbacks/137329.aspx</trackback:ping>
        </item>
        <item>
            <title>Static Reflection in .Net</title>
            <link>http://geekswithblogs.net/btudor/archive/2009/10/12/135423.aspx</link>
            <description>&lt;h2&gt;Static Reflection in .Net&lt;/h2&gt;  &lt;p&gt;Where have I been?&lt;/p&gt;  &lt;p&gt;I recently took a few minutes to look through the latest &lt;a href="http://msdn.microsoft.com/en-us/magazine/default.aspx"&gt;MSDN magazine&lt;/a&gt; and ran across &lt;a href="http://msdn.microsoft.com/en-us/magazine/ee309512.aspx"&gt;a nice article by Jeremy Miller&lt;/a&gt; on “Functional Programming for Everyday .NET Development”. The section titled “Lambdas as Data” was my first introduction to static reflection in .Net. Where the heck have I been? I don’t write database persistence code, so I am not familiar with NHibernate (or fluent NHibernate) (which is where Jeremy’s sample comes from), but I am still surprised at how little I understand about everything Linq brought to the .Net party. A quick search around the internet reveals &lt;a href="http://www.lostechies.com/blogs/chad_myers/archive/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper.aspx"&gt;this topic is well-covered&lt;/a&gt;, and several years old.&lt;/p&gt;  &lt;h2&gt;Example Code&lt;/h2&gt;  &lt;p&gt;Suppose you have a need to dynamically discover properties on an object. Easy, right? After all, that’s what the System.Reflection namespaces is for! However..&lt;/p&gt;  &lt;p&gt;Let’s look at a class named “SomeObject” with a property “SomeProperty”:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;class&lt;/span&gt; SomeObject&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; SomeProperty { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;You can use&lt;em&gt; so-called&lt;/em&gt; “static reflection” like this:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Program&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Main(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;         SomeObject o = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SomeObject()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;             SomeProperty = &lt;span style="color: #006080"&gt;"Test"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;         };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;         staticReflection(o, e =&amp;gt; e.SomeProperty);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;         Console.ReadKey();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; staticReflection&amp;lt;T&amp;gt;(T o, Expression&amp;lt;Func&amp;lt;T,&lt;span style="color: #0000ff"&gt;object&lt;/span&gt;&amp;gt;&amp;gt; expression)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;         MemberExpression me = expression.Body &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; MemberExpression;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (me != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; me.Member.MemberType == System.Reflection.MemberTypes.Property)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;             Console.WriteLine(&lt;span style="color: #006080"&gt;"Property: '{0}' of type '{1}' has value '{2}'."&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;                 me.Member.Name,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;                 expression.Body.Type,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;                 expression.Compile().Invoke(o)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;                 );&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The output is:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;font size="3" face="Courier New"&gt;Property: 'SomeProperty' of type 'System.String' has value 'Test'.&lt;/font&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Very cool. Now I need to understand why the second argument has to be something like Expression&amp;lt;Func&amp;lt;T, object&amp;gt;&amp;gt; rather than simply Expression&amp;lt;T&amp;gt;. If the latter is used, the compiler rewards me with:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;font size="3" face="Courier New"&gt;Error    1    Cannot convert lambda to an expression tree whose type argument 'StaticReflection.SomeObject' is not a delegate type&lt;/font&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It’s the whole “return type” thing on the delegate that throws me as well – where does that come from? In my code sample I have declared the Func return type as type “object” (it is actually a string in my case). Why don’t I have to do something like “e =&amp;gt; {return e.SomeProperty;}”, and how come a lambda expression with a statement body like that cannot be converted into an expression tree (compiler’s words, not mine)?&lt;/p&gt;

&lt;p&gt;I still have a little more learning to do before really understanding what’s going on here. My suspicion is that Linq brought a heck of a lot more to the party than it might appear at first look.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/btudor/aggbug/135423.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bill Tudor</dc:creator>
            <guid>http://geekswithblogs.net/btudor/archive/2009/10/12/135423.aspx</guid>
            <pubDate>Mon, 12 Oct 2009 17:08:21 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/btudor/comments/135423.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/btudor/archive/2009/10/12/135423.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/btudor/comments/commentRss/135423.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/btudor/services/trackbacks/135423.aspx</trackback:ping>
        </item>
        <item>
            <title>Designing Software for Scientists</title>
            <link>http://geekswithblogs.net/btudor/archive/2009/10/06/135325.aspx</link>
            <description>&lt;h1&gt;Designing Software for Scientists&lt;/h1&gt;  &lt;p&gt;Creating a software design for scientists can be tricky business. Unlike the businessman, who is better off looking at the pretty database report or marveling over the catchy name of the latest &lt;em&gt;Forms over Data&lt;/em&gt; application, the scientist can actually contribute to the implementation – provided you use the right architecture. In year’s past (I’m referring to 20+ years ago), the typical Physicist / Chemist / etc. was &lt;em&gt;nearly on par&lt;/em&gt; with the typical software engineer / computer scientists with respect to software design skills. Although the scientific community of that time preferred the ‘&lt;em&gt;GOTO’&lt;/em&gt;, they nevertheless understood the value of using subroutines to nearly the same degree as a computer scientists. &lt;/p&gt;  &lt;p&gt;Not so, today. Software design has come a long way since then.&lt;/p&gt;  &lt;h3&gt;Software Design has Matured&lt;/h3&gt;  &lt;p&gt;Software design has matured. We have terms like inheritance and encapsulation. We talk about singletons, abstract factories, and chain of responsibility. We use terms like polymorphism, covariance, and contravariance (as applied to software design). We compose systems with Inversion of Control containers. Mock objects are used for unit testing. Reflection, dynamic and static languages. The discipline of software engineering has matured to a point where the typical scientist cannot possibly hope to understand what makes a well-design system – no more than a software engineer can understand how to model protein folding of polypeptides. &lt;/p&gt;  &lt;p&gt;So how do we design software so that other scientists and engineers can participate in the implementation? Here are some ideas.&lt;/p&gt;  &lt;h4&gt;1. Keep it Simple.&lt;/h4&gt;  &lt;p&gt;Don’t compose in an IoC container – too abstract. Do use layers, repositories, and multiple program units. Scientists understand process control, state transitions, and other engineering/scientific/mathematics concepts so use them in your software designs. [Object models? Not sure where I stand on this one. There might be a whole blog post in here somewhere.]&lt;/p&gt;  &lt;h4&gt;2. Work in Pairs&lt;/h4&gt;  &lt;p&gt;Match a subject matter expert with a software design expert. &lt;/p&gt;  &lt;h4&gt;3. Limit Participation&lt;/h4&gt;  &lt;p&gt;Limit the “coding” performed by the scientist to the functional code, not the design. The infrastructure, layout, program flow as well as all meta-design elements (project structure, build environment, coding standards, etc.) – essentially &lt;em&gt;the software design&lt;/em&gt;, should be strictly the realm of the software architect. Leave the algorithms for the subject matter expert. &lt;/p&gt;  &lt;h4&gt;4. Move the problem domain.&lt;/h4&gt;  &lt;p&gt;Let the scientists program in their own “language” - provide a scripting component, meta-programming, or data-driven model such that the subject matter expert remains closer to their problem domain, even if this means additional software (such as interpreters, data transformation engines) must be developed. In a really large system, you might go so far as to develop a rules engine or other knowledge base approach.&lt;/p&gt;  &lt;h4&gt;5. Use Abstractions&lt;/h4&gt;  &lt;p&gt;The nature of software is to provide abstractions. This also happens to be common of all science and engineering. You can use your entire software design Bag ‘o Tricks provided you supply an appropriate level of abstraction over top. Explain the abstraction, and the typical scientist will have no trouble using it, even if they really don’t know what is going on. So in spite of the first idea listed here, you &lt;em&gt;can&lt;/em&gt; fire up your favorite IoC container and use it – as long as you provide the right abstraction for your scientific colleagues.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/btudor/aggbug/135325.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bill Tudor</dc:creator>
            <guid>http://geekswithblogs.net/btudor/archive/2009/10/06/135325.aspx</guid>
            <pubDate>Tue, 06 Oct 2009 10:02:48 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/btudor/comments/135325.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/btudor/archive/2009/10/06/135325.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/btudor/comments/commentRss/135325.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/btudor/services/trackbacks/135325.aspx</trackback:ping>
        </item>
        <item>
            <title>The &amp;ldquo;Web Application&amp;rdquo; Must Die</title>
            <link>http://geekswithblogs.net/btudor/archive/2009/09/14/134795.aspx</link>
            <description>&lt;p&gt;Remember when a program was termed a “GUI Application” - a program with a &lt;em&gt;G&lt;/em&gt;raphical &lt;em&gt;U&lt;/em&gt;ser &lt;em&gt;I&lt;/em&gt;nterface? It had features like menus that “dropped-down” (or “popped up”), scroll bars to reveal more of the virtual surface area, a pointing device (still called a &lt;em&gt;cursor&lt;/em&gt;), and lots and lots of Drag &amp;amp; Drop. Thankfully, that moniker has mostly died. Now it is time another term to fall by the wayside – the &lt;em&gt;Web Application&lt;/em&gt;.&lt;/p&gt;  &lt;h3&gt;What is a Web Application?&lt;/h3&gt;  &lt;p&gt;Just what is a web application, anyway. An application delivered over the web? A Java applet, flash, or silverlight program running in a browser? How about HTML+Javascript with lots of Ajaxy asynchronous updating? What about plain old static HTML pages with hyperlinks to navigate between them?&lt;/p&gt;  &lt;h3&gt;Who are Web Developers?&lt;/h3&gt;  &lt;p&gt;Just who are these web developers? Are they PHP junkies, ASP.net gurus, Flex monkeys? Are the real web developers HTML+CSS+JavaScriptors? Rails developers? Web site designers? What about a C++ application that runs locally yet stores data in the cloud or communicates with other instances on the internet? &lt;em&gt;Is the twitter client a web application?&lt;/em&gt;&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;&lt;em&gt;The ubiquitous internet makes every application a web application. The term has lost its meaning, and the term must die.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;Just like “GUI”. If an application requires a user interface, it will be a &lt;em&gt;graphical&lt;/em&gt; one. If an application requires communication between computers, or presence on more than one computer, it will use the “&lt;em&gt;Web&lt;/em&gt;”. In one way or another. Server side, client side, I don’t care. These days, every “application” is a “web application”.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/btudor/aggbug/134795.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bill Tudor</dc:creator>
            <guid>http://geekswithblogs.net/btudor/archive/2009/09/14/134795.aspx</guid>
            <pubDate>Mon, 14 Sep 2009 09:55:56 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/btudor/comments/134795.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/btudor/archive/2009/09/14/134795.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/btudor/comments/commentRss/134795.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/btudor/services/trackbacks/134795.aspx</trackback:ping>
        </item>
        <item>
            <title>The Joel Test &amp;ndash; Updated for 2010</title>
            <link>http://geekswithblogs.net/btudor/archive/2009/06/16/132842.aspx</link>
            <description>&lt;p&gt;The &lt;a href="http://www.joelonsoftware.com/articles/fog0000000043.html" target="_blank"&gt;Joel test&lt;/a&gt; is intended to gauge the quality of a software development organization. Ten years later, it is in need of an update. Below is a possible “New Joel Test”, updated for 2010. &lt;/p&gt;  &lt;h2&gt;&lt;strike&gt;1. Do you use source control?&lt;/strike&gt;&lt;/h2&gt;  &lt;h2&gt;1. Do you have a change management system?&lt;/h2&gt;  &lt;p&gt;There needs to be a configuration management plan, control of assets beyond “source code”, branching and merging strategy (even if it’s not to branch), release stabilization and deployment plan, security permissions and roles, quality gates for checking and/or merge, etc. Otherwise, “use source control” is just referring to a &lt;em&gt;glorified backup system&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;h2&gt;&lt;strike&gt;2. Can you make a build in one step?&lt;/strike&gt;&lt;/h2&gt;  &lt;h2&gt;2. Can everyone make a build in one step?&lt;/h2&gt;  &lt;p&gt;Individual developers need access to the automated build system. The official nightly build can “build everything”, but developers need to be able to build individual parts, pull together the required assets, and run from a representative staging area – maybe a virtual machine (or two), a network share, or just a folder on disk.&lt;/p&gt;  &lt;h2&gt;&lt;strike&gt;3. Do you make daily builds?&lt;/strike&gt;&lt;/h2&gt;  &lt;h2&gt;3. Do your daily build include automated tests?&lt;/h2&gt;  &lt;p&gt;It’s not enough to just &lt;em&gt;build&lt;/em&gt; – we need an indication of build quality. “Break the build” should mean more than “does not compile”, it should also mean “does not pass the tests”.&lt;/p&gt;  &lt;h2&gt;&lt;strike&gt;4. Do you have a bug database?&lt;/strike&gt;&lt;/h2&gt;  &lt;h2&gt;4. Is work item tracking integrated with source control?&lt;/h2&gt;  &lt;p&gt;What artifacts were changed with a given bug fix? What bug or development task is associated with the most recent change-set? Which bugs are associated with a given merge? &lt;/p&gt;  &lt;p&gt;Check-outs (or commits, depending on the source control system in use), must be associated with bug reports or development tasks. Each check-in should reflect changes for one task (unless they are coupled tasks). You should also be able to query, based on a bug report, which artifacts were changed (or ideally, currently in the process of being changed). In other words, change management must be integrated with bug tracking and project task tracking.&lt;/p&gt;  &lt;h2&gt;&lt;strike&gt;5. Do you fix bugs before writing new code?&lt;/strike&gt;&lt;/h2&gt;  &lt;h2&gt;5. Do you fix bugs &lt;em&gt;and&lt;/em&gt; write new code?&lt;/h2&gt;  &lt;p&gt;A properly run project will have a branching / merging strategy (or tagging/labeling policy) that allows simultaneous bug fixes with new development. A quality organization will be able to correct bugs in previous releases, and ensure those corrections are in the current release. Without copying or duplicating the code base.&lt;/p&gt;  &lt;h2&gt;&lt;strike&gt;6. Do you have an up-to-date schedule?&lt;/strike&gt;&lt;/h2&gt;  &lt;h2&gt;6. Do you track progress and manage change?&lt;/h2&gt;  &lt;p&gt;Project tracking must include processes that allow for managing (planning / executing / tracking) change as well as tracking progress and periodic re-planning of the remaining work.&lt;/p&gt;  &lt;h2&gt;&lt;strike&gt;7. Do you have a spec?&lt;/strike&gt;&lt;/h2&gt;  &lt;h2&gt;7. Do you have a requirements management system?&lt;/h2&gt;  &lt;p&gt;The “&lt;em&gt;spec&lt;/em&gt;” will change; that change needs to be managed. Too often I see organizations with an excellent process for development of the “spec” and a horrible process for managing change in the spec. &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Note: In 2010, if you don’t have a “&lt;em&gt;spec&lt;/em&gt;”, you automatically get a ZERO on the new Joel Test and there is no point in continuing on.&lt;/p&gt; &lt;/blockquote&gt;  &lt;h2&gt;&lt;strike&gt;8. Do programmers have quiet working conditions?&lt;/strike&gt;&lt;/h2&gt;  &lt;h2&gt;8. Do programmers have quiet working conditions and teaming rooms?&lt;/h2&gt;  &lt;p&gt;The teaming rooms are more than a room with a white-board. There is a conference phone, computers (more than one), projector, and lots of white boards. Code reviews, code walk-through, mentoring, design, dispute resolution, meeting with customers – can all take place here. &lt;/p&gt;  &lt;h2&gt;9. Do you use the best tools money can buy?&lt;/h2&gt;  &lt;p&gt;No change needed. This one is timeless. &lt;/p&gt;  &lt;h2&gt;&lt;strike&gt;10. Do you have testers?&lt;/strike&gt;&lt;/h2&gt;  &lt;h2&gt;10. Are your testers involved in requirements management?&lt;/h2&gt;  &lt;p&gt;The test team needs to be involved in the requirements management system as well as the product validation process. Tests are executed against the requirements. The testers should have authority to approve/reject a deployment as well as approve or reject a requirement. Otherwise, &lt;em&gt;they’re just testers&lt;/em&gt;.&lt;/p&gt;  &lt;h2&gt;&lt;strike&gt;11. Do new candidates write code during their interview?&lt;/strike&gt;&lt;/h2&gt;  &lt;h2&gt;11. Do new candidates review code during their interview?&lt;/h2&gt;  &lt;p&gt;“Writing code” is one thing – understanding code is another. Candidates should be able to answer questions like “is this code thread-safe?”, “is the code well-commented?”, or “Is the implementation appropriate” – and why. Printing fizz-buzz is one thing; being able to appropriately critique a page of code is another. As a bonus, you could always ask them to &lt;em&gt;re-write&lt;/em&gt; it and get the best of both.&lt;/p&gt;  &lt;h2&gt;12. Do you do hallway usability testing?&lt;/h2&gt;  &lt;p&gt;Huh? I’ll have to go and read the original on this one, again. I will leave it alone here.&lt;/p&gt;  &lt;p&gt;*  *  *  *  *&lt;/p&gt;  &lt;p&gt;The Joel Test updated for the year 2010. And a few more months to get it right.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/btudor/aggbug/132842.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bill Tudor</dc:creator>
            <guid>http://geekswithblogs.net/btudor/archive/2009/06/16/132842.aspx</guid>
            <pubDate>Tue, 16 Jun 2009 09:23:07 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/btudor/comments/132842.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/btudor/archive/2009/06/16/132842.aspx#feedback</comments>
            <slash:comments>15</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/btudor/comments/commentRss/132842.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/btudor/services/trackbacks/132842.aspx</trackback:ping>
        </item>
        <item>
            <title>Top 5 Programmer Mistakes</title>
            <link>http://geekswithblogs.net/btudor/archive/2009/05/04/131811.aspx</link>
            <description>&lt;p&gt;This post is not another list of security mistakes in web application development – not my cup of tea. No, this is a list of the top five &lt;strong&gt;&lt;em&gt;programmer&lt;/em&gt;&lt;/strong&gt; errors. That is, errors made by software development professionals performing their craft.&lt;/p&gt;  &lt;h2&gt;No. 1 – Writing Too Much Code&lt;/h2&gt;  &lt;blockquote&gt;   &lt;p&gt;“&lt;em&gt;If I have seen further it is only by standing on the shoulders of giants&lt;/em&gt;” – Sir Isaac Newton.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I recently came across &lt;a href="http://geekswithblogs.net/cwilliams/archive/2009/04/29/131596.aspx" target="_blank"&gt;this post&lt;/a&gt; by &lt;a href="http://geekswithblogs.net/cwilliams/Default.aspx" target="_blank"&gt;Chris Williams&lt;/a&gt; asking for help in finding a bug that resulted in “serious error in the debugger”. There were actually several bugs in the code, some worse than others. One of the proposed solutions also produced a new bug, though less serious. The bottom line – a whole bunch of code could be replaced with a single library call. Now, it’s nice that today’s frameworks have lots of high level method calls preventing you from writing too much code. But what is really nice is that the less code you write, the less bugs you insert into your projects. Failure to take advantage of this gift comes in as the number one mistake programmer’s make. &lt;/p&gt;  &lt;p&gt;Don’t write so much code!&lt;/p&gt;  &lt;h2&gt;No. 2 – Ignoring the Problem Domain&lt;/h2&gt;  &lt;p&gt;How many times have you seen an “ini” file reader that simply trades one storage mechanism (an INI file on disk) for another (a dictionary of key/value pairs). What’s the point? While this may be appropriate as a middle-tier step, there is a problem domain in there somewhere, right? A “To Do” application with categories can store its information in a ini file (or any other back-end store), but when I read it from storage, I want the result to be a collection of categories, each with collections of tasks hanging off of them. Not some dictionary for me to parse later (typically throughout the application several times over).&lt;/p&gt;  &lt;p&gt;Move closer to the problem domain. Whatever your application is. If you are developing a generic solution/library, use a layered approach with problem-domain specific objects built on top of generic, low-level objects. Solving problems with data structures (consider the &lt;em&gt;System.Data.DataSet&lt;/em&gt; object in .Net) shows up often enough to make this the number two mistake that programmers make.&lt;/p&gt;  &lt;p&gt;Don’t ignore the problem domain.&lt;/p&gt;  &lt;h2&gt;No. 3 – Inappropriate Level of Rigor&lt;/h2&gt;  &lt;p&gt;Everyone likes &lt;em&gt;one size fits all&lt;/em&gt;. Too bad one size never really fits all. Not enough design, too much design. Not enough specification, too much specification. Not enough test, too much test. Not enough extensibility, too much extensibility. Not enough documentation, too much documentation. Zealots in some of these areas will let you know that you can never have enough ___. You can always have too much X. More often, there’s too little: Design, specification. Sometimes, there is to much: extensibility. Sometimes both extremes are common: Test. [Nobody knows what to say about documentation – we like to say ‘never enough’ while refusing to read what little is there]. I don’t know what the correct level of rigor for your project is, but if you don’t think about it – and just do whatever you did before – you are making the number three mistake on my list.&lt;/p&gt;  &lt;p&gt;Consider the level of rigor for each project you undertake.&lt;/p&gt;  &lt;h2&gt;No. 4 – Programming by Accident&lt;/h2&gt;  &lt;blockquote&gt;   &lt;p&gt;“&lt;em&gt;Works for me&lt;/em&gt;” – anonymous&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;When you don’t know why something works – find out. There is a world of difference between “working code” and “good code”. Never be satisfied with “getting lucky”. Your test case works, but you don’t know why. Not a good place to be. Understand what you are doing, understand why it works, understand when it works, and more importantly understand when it does not work. If you don’t know something – you have work to do. If you take a look at the post mentioned at the start of this document, the author states that in one case “Button1 read in File1 via a StreamReader &lt;em&gt;&lt;strong&gt;and works perfectly&lt;/strong&gt;&lt;/em&gt;”. No, it worked in that case &lt;em&gt;by accident&lt;/em&gt;. If it works for you, but you don’t know why, then you are making the number four programmer mistake – programming by accident.&lt;/p&gt;  &lt;p&gt;Don’t program by accident. &lt;/p&gt;  &lt;h2&gt;No. 5 – Tools are Not the Answer&lt;/h2&gt;  &lt;p&gt;Tools are great, but they are never the answer. Tools improve productivity. Tools used correctly improve quality, but they do not solve problems. Tools are good for problems that have already been solved, not ones that need programmers to solve them. Your tools will change, and there will always been another tool. The number five mistake programmers make – suggesting a new tool for an old problem.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/btudor/aggbug/131811.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bill Tudor</dc:creator>
            <guid>http://geekswithblogs.net/btudor/archive/2009/05/04/131811.aspx</guid>
            <pubDate>Tue, 05 May 2009 03:17:39 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/btudor/comments/131811.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/btudor/archive/2009/05/04/131811.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/btudor/comments/commentRss/131811.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/btudor/services/trackbacks/131811.aspx</trackback:ping>
        </item>
        <item>
            <title>Top 5 Network Programming Mistakes</title>
            <link>http://geekswithblogs.net/btudor/archive/2009/02/17/129140.aspx</link>
            <description>&lt;p&gt;Here are my top five. What are yours?&lt;/p&gt;  &lt;h3&gt;No. 1 Failure to clearly define a network protocol&lt;/h3&gt;  &lt;p&gt;In today’s world of &lt;em&gt;everything over HTTP&lt;/em&gt;, designing low-level network protocols are mostly a thing of the past. Behind the firewall, however, failure to clearly define a network protocol before implementation is one of the largest sources of re-work.&lt;/p&gt;  &lt;p&gt;Take the time to clearly define the network communication protocols – at whatever level is required for your application. Even if you are running over HTTP, define the application level protocols in such a way that implementation is easier, interoperability is easier, states and state transitions are well known, and always make maximum use of existing protocols in the design.&lt;/p&gt;  &lt;p&gt;This error comes in No. 1 since it leads to an exponential increase in development and maintenance hours. And it cannot be easily re-factored out.&lt;/p&gt;  &lt;h3&gt;No. 2 Incorrectly Reading and Writing data over TCP&lt;/h3&gt;  &lt;p&gt;In most sockets libraries, writing N bytes to a TCP connection may result in less than N bytes transmitted. Similarly, asking for N bytes returns anywhere from 1 to N bytes (assuming no errors). You must continue to call read/write until the entire message defined by your protocol is sent or received. &lt;/p&gt;  &lt;p&gt;For example, the Win32 API &lt;em&gt;send&lt;/em&gt;() and &lt;em&gt;recv&lt;/em&gt;() functions can send or receive less than the requested data amount. Most of the time, all of the data will be sent/received in one chunk - &lt;em&gt;particularly if the message size is small&lt;/em&gt;. So poorly written code with this error “works” nearly all of the time – but not all the time.&lt;/p&gt;  &lt;p&gt;This behavior is library dependant. For example, the &lt;em&gt;Write&lt;/em&gt;() method on the NetworkStream class in .Net will block until all of your bytes are sent. On the other hand, the &lt;em&gt;Send&lt;/em&gt;() method on the Socket class in the same library will either block until all bytes are sent, or, if placed in non-blocking mode, will behave like the &lt;em&gt;send&lt;/em&gt;() function described earlier and it then becomes your job to get all the bytes out the door. The &lt;em&gt;Read&lt;/em&gt;() method on any of these entities (NetworkStream, Socket) can always return less than the requested number of bytes. &lt;/p&gt;  &lt;p&gt;I see code all the time where a service application sends a message block of, say, 100 bytes over TCP. The client reads 100 bytes at a time from the network but has no ability to react to receiving a partial message. In such a scenario, the application works most of the time – just not all of the time – which is why this issue clocks in at No. 2.&lt;/p&gt;  &lt;h3&gt;No. 3 Validating Protocols&lt;/h3&gt;  &lt;p&gt;I confess right now: I am no expert in network security. I live mostly behind the firewall and off the public internet. However, failure to validate network messages even when you fully control both sides of the client – server equation comes in at No. 3. Even if the protocol errors are not malicious, failure to validate data results in both crashes and hard to find bugs, if not security holes. For example, if your protocol contains a payload length as part of the data, verify that you actually read that length of data before attempting to access it.&lt;/p&gt;  &lt;h3&gt;No. 4 Buffer Overflows&lt;/h3&gt;  &lt;p&gt;When writing network programming code, you typically will define some fixed size buffers. While this is not always the case, performance and scalability issues tend to force you in that direction. Enough said – don’t overflow any fixed size buffers that you have defined. If we are talking network security, this error might be number one. For this discussion, it comes in at No. 4.&lt;/p&gt;  &lt;h3&gt;No. 5 Improper Error Handling&lt;/h3&gt;  &lt;p&gt;Network programming code must plan for errors – remote client goes down, network switch goes down, a router fails, a network cable becomes un-plugged. Nearly all the network programming code I come across dutifully checks for errors with each network API method call. This is a good thing. What the code does in the case of error, however, is where the problems come into play. Some examples: Gobble up all errors; Failure to design in any sort of logging/trace system; re-transmitting data in endless loops, etc., I see nice error checking, &lt;em&gt;but poor error handling&lt;/em&gt;, often enough to make this item No. 5.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/btudor/aggbug/129140.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bill Tudor</dc:creator>
            <guid>http://geekswithblogs.net/btudor/archive/2009/02/17/129140.aspx</guid>
            <pubDate>Tue, 17 Feb 2009 09:11:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/btudor/comments/129140.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/btudor/archive/2009/02/17/129140.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/btudor/comments/commentRss/129140.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/btudor/services/trackbacks/129140.aspx</trackback:ping>
        </item>
    </channel>
</rss>
