<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Yet Another Coding Blog : programming</title><link>http://blogs.msdn.com/avip/archive/tags/programming/default.aspx</link><description>Tags: programming</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Useful C# method for unit testing</title><link>http://blogs.msdn.com/avip/archive/2009/07/16/useful-c-method-for-unit-testing.aspx</link><pubDate>Thu, 16 Jul 2009 06:37:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9835029</guid><dc:creator>Avi Pilosof</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/avip/comments/9835029.aspx</comments><wfw:commentRss>http://blogs.msdn.com/avip/commentrss.aspx?PostID=9835029</wfw:commentRss><wfw:comment>http://blogs.msdn.com/avip/rsscomments.aspx?PostID=9835029</wfw:comment><description>&lt;p&gt;I’m unit testing a UI that needs to show some lists in various sorted orders, and I wanted to ensure that my tests would cover that. I found this method to come in handy:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsOrderedBy&amp;lt;T&amp;gt;(&lt;span class="kwrd"&gt;this&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt; coll,&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;                   Func&amp;lt;T, IComparable&amp;gt; val)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (coll == &lt;span class="kwrd"&gt;null&lt;/span&gt; || coll.Count() == 0)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    var curVal = val(coll.ElementAt(0));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; coll.Count(); i++)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (val(coll.ElementAt(i)).CompareTo(curVal) &amp;lt; 0)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        curVal = val(coll.ElementAt(i));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Here’s how to determine if a simple array is in order:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;var arr = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt;[] { 1, 2, 3, 5 };
&lt;span class="kwrd"&gt;bool&lt;/span&gt; ordered = arr.IsOrderedBy(i =&amp;gt; i);&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Here’s how you’d call it on a more complex object:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;var arr = Enumerable.Range(1, 10)
    .Select(e =&amp;gt; &lt;span class="kwrd"&gt;new&lt;/span&gt;
    {
        Name = &lt;span class="str"&gt;&amp;quot;bob&amp;quot;&lt;/span&gt;,
        Salary = 10 * e
    });
&lt;span class="kwrd"&gt;bool&lt;/span&gt; ordered = arr.IsOrderedBy(i =&amp;gt; i.Salary);&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Avi&lt;/p&gt;

&lt;p&gt;&lt;script type="text/javascript"&gt;addthis_pub  = 'avip';&lt;/script&gt;
&lt;a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"&gt;&lt;img src="http://s7.addthis.com/button0-share.gif" width="83" height="16" border="0" alt="" /&gt;&lt;/a&gt;&lt;script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"&gt;&lt;/script&gt;
&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9835029" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/avip/archive/tags/programming/default.aspx">programming</category></item><item><title>Live Mesh Applications – whoah.</title><link>http://blogs.msdn.com/avip/archive/2009/02/17/live-mesh-applications-whoah.aspx</link><pubDate>Tue, 17 Feb 2009 01:52:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9426640</guid><dc:creator>Avi Pilosof</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/avip/comments/9426640.aspx</comments><wfw:commentRss>http://blogs.msdn.com/avip/commentrss.aspx?PostID=9426640</wfw:commentRss><wfw:comment>http://blogs.msdn.com/avip/rsscomments.aspx?PostID=9426640</wfw:comment><description>&lt;p&gt;I’ve been playing with &lt;a href="http://mesh.live.com"&gt;Live Mesh&lt;/a&gt; for a long time now, and have been loving it. During this time I’d been hearing about &lt;em&gt;applications&lt;/em&gt; for Live Mesh, and while it sounded interesting in theory I didn’t really get what the point would be.&lt;/p&gt;  &lt;p&gt;Then I watched this video:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://briangorbett.com/mesh/mesh-video-player/" href="http://briangorbett.com/mesh/mesh-video-player/"&gt;http://briangorbett.com/mesh/mesh-video-player/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The video walks you through the development process of a Live Mesh app. The “whoah” moment is when I realized that the one codebase - without any special code - created an application that ran identically on the web and on the desktop. Money shot starts at about 25:30; but it helps to watch the whole vid.&lt;/p&gt;  &lt;p&gt;This is fascinating; this is a “Web OS” (I hate that term).&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Avi&lt;/p&gt;  &lt;p&gt;&lt;script type="text/javascript"&gt;addthis_pub  = 'avip';&lt;/script&gt;
&lt;a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"&gt;&lt;img src="http://s7.addthis.com/button0-share.gif" width="83" height="16" border="0" alt="" /&gt;&lt;/a&gt;&lt;script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"&gt;&lt;/script&gt;
&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9426640" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/avip/archive/tags/silverlight/default.aspx">silverlight</category><category domain="http://blogs.msdn.com/avip/archive/tags/programming/default.aspx">programming</category><category domain="http://blogs.msdn.com/avip/archive/tags/mesh/default.aspx">mesh</category></item><item><title>Be Paranoid. Be Very Paranoid.</title><link>http://blogs.msdn.com/avip/archive/2008/12/03/be-paranoid-be-very-paranoid.aspx</link><pubDate>Wed, 03 Dec 2008 06:29:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9168003</guid><dc:creator>Avi Pilosof</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/avip/comments/9168003.aspx</comments><wfw:commentRss>http://blogs.msdn.com/avip/commentrss.aspx?PostID=9168003</wfw:commentRss><wfw:comment>http://blogs.msdn.com/avip/rsscomments.aspx?PostID=9168003</wfw:comment><description>&lt;p&gt;Do you maintain an application with a backend database? Does that application ever write to the database? Be afraid.&lt;/p&gt;  &lt;p&gt;The worst situation to be in with respect to the above is when a customer mails you and says: “Why is my data gone?”&lt;/p&gt;  &lt;p&gt;99% of the time, it’s because they clicked on the “Delete” button; but sometimes you need proof – this is what I want to discuss.&lt;/p&gt;  &lt;p&gt;Log every interesting write to the database. There are various levels at which you can do this:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Application logic level: This gives you the most context, the most usable logs, and in fact gives you data which can generally be exposed directly to the customer, preventing lots of questions. The problem is that it’s not reliable: The app could succeed in writing then fail in logging. Alternatively, a dev on the app might forget to add logging to a new feature. &lt;/li&gt;    &lt;li&gt;Application object model level: A little less context/readability than above, a little more reliability. &lt;/li&gt;    &lt;li&gt;Data-Access-Layer level: Less context than above, more reliability. &lt;/li&gt;    &lt;li&gt;Sproc level: Same tradeoff. &lt;/li&gt;    &lt;li&gt;Table level (triggers): And same again. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;As you can see, the lower you go, the less chance for error and the less value a log entry gives you. You can increase the value of a “deep” log entry by forcing a set of arguments up the stack. For example, you can force every sproc which writes data to require username/machine/reason arguments – but this can become costly to maintain.&lt;/p&gt;  &lt;p&gt;So which is right? Depends on your app, your level of paranoia, your customer’s needs, etc. Generally I stay away from triggers and try to add logging at the sproc level for critical sprocs, and at the app/OM level for extra context; better to have too much logging than too little.&lt;/p&gt;  &lt;p&gt;Here’s a nice trick for creating a footprint log table that your sprocs (or triggers) can use quite easily - Create a simple table with the following columns (at least):&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" width="400"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="92"&gt;&lt;strong&gt;Name&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="97"&gt;&lt;strong&gt;Default value&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="210"&gt;&lt;strong&gt;Comment&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="92"&gt;LogEntry&lt;/td&gt;        &lt;td valign="top" width="97"&gt;&amp;#160;&lt;/td&gt;        &lt;td valign="top" width="210"&gt;The text you want to log.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="92"&gt;TimeStamp&lt;/td&gt;        &lt;td valign="top" width="97"&gt;getdate()&lt;/td&gt;        &lt;td valign="top" width="210"&gt;Automatically fills in the current datetime.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="92"&gt;User&lt;/td&gt;        &lt;td valign="top" width="97"&gt;system_user&lt;/td&gt;        &lt;td valign="top" width="210"&gt;Automatically inserts the logged in user’s ID.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="92"&gt;Machine&lt;/td&gt;        &lt;td valign="top" width="97"&gt;host_name()&lt;/td&gt;        &lt;td valign="top" width="210"&gt;Automatically inserts the user’s client machine name.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="92"&gt;Application&lt;/td&gt;        &lt;td valign="top" width="97"&gt;app_name()&lt;/td&gt;        &lt;td valign="top" width="210"&gt;Automatically inserts the name of the application running this code (provided you set it in the connection string, which you should!)&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Inserting into this table requires only the one column, but you capture lots of extra data for free. If this is done from a trigger, then you’ll even catch slackers with access to the DB who are updating it manually.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Oh, don’t forget to age off old entries before the table ends up at 50GB ;)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Avi&lt;/p&gt;  &lt;p&gt;&lt;script type="text/javascript"&gt;addthis_pub  = 'avip';&lt;/script&gt;
&lt;a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"&gt;&lt;img src="http://s7.addthis.com/button0-share.gif" width="83" height="16" border="0" alt="" /&gt;&lt;/a&gt;&lt;script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"&gt;&lt;/script&gt;
&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9168003" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/avip/archive/tags/architecture/default.aspx">architecture</category><category domain="http://blogs.msdn.com/avip/archive/tags/programming/default.aspx">programming</category></item><item><title>Trivial but useful extension method</title><link>http://blogs.msdn.com/avip/archive/2008/09/30/trivial-but-useful-extension-method.aspx</link><pubDate>Tue, 30 Sep 2008 08:34:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8969872</guid><dc:creator>Avi Pilosof</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/avip/comments/8969872.aspx</comments><wfw:commentRss>http://blogs.msdn.com/avip/commentrss.aspx?PostID=8969872</wfw:commentRss><wfw:comment>http://blogs.msdn.com/avip/rsscomments.aspx?PostID=8969872</wfw:comment><description>&lt;p&gt;Don’t know why I didn’t write this before; it makes code very readable. Often when you write anything graphics related, you want to constrain coordinates to window edges (for example).&lt;/p&gt;  &lt;p&gt;So a simple method:&lt;/p&gt;  &lt;div&gt;   &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;     &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// Ensure that the given number falls within the&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// given min/max constraints.&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt; &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; Constrain( &lt;span style="color: #0000ff"&gt;this&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; num,&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;                         &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; min, &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; max )&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (num &amp;lt; min)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; min;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (num &amp;gt; max)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; max;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; num;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;It’s just a Floor combined with a Ceiling, but it reads nicely:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; xform.X = dx.Constrain(-&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.ActualWidth, 0 );&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; xform.Y = dy.Constrain(-&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.ActualHeight, 0 );&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Avi&lt;/p&gt;

&lt;p&gt;&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href="http://www.addthis.com/bookmark.php" onclick="window.open('http://www.addthis.com/bookmark.php?wt=nw&amp;pub=avip&amp;url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title), 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100'); return false;" title="Bookmark and Share" target="_blank"&gt;&lt;img src="http://s9.addthis.com/button1-share.gif" wid&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8969872" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/avip/archive/tags/programming/default.aspx">programming</category></item><item><title>On using Arrays</title><link>http://blogs.msdn.com/avip/archive/2008/09/23/on-using-arrays.aspx</link><pubDate>Tue, 23 Sep 2008 03:52:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8961772</guid><dc:creator>Avi Pilosof</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/avip/comments/8961772.aspx</comments><wfw:commentRss>http://blogs.msdn.com/avip/commentrss.aspx?PostID=8961772</wfw:commentRss><wfw:comment>http://blogs.msdn.com/avip/rsscomments.aspx?PostID=8961772</wfw:comment><description>&lt;p&gt;Eric Lippert has a great article on arrays:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://blogs.msdn.com/ericlippert/archive/2008/09/22/arrays-considered-somewhat-harmful.aspx" href="http://blogs.msdn.com/ericlippert/archive/2008/09/22/arrays-considered-somewhat-harmful.aspx"&gt;http://blogs.msdn.com/ericlippert/archive/2008/09/22/arrays-considered-somewhat-harmful.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I think this is especially useful to consider if you’re writing an API. Consider not just arrays, but any time you’re returning any collection: Are you returning &lt;em&gt;values&lt;/em&gt; or a &lt;em&gt;variables&lt;/em&gt;? Did you mean to?&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Avi&lt;/p&gt;  &lt;p&gt;&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href="http://www.addthis.com/bookmark.php" onclick="window.open('http://www.addthis.com/bookmark.php?wt=nw&amp;pub=avip&amp;url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title), 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100'); return false;" title="Bookmark and Share" target="_blank"&gt;&lt;img src="http://s9.addthis.com/button1-share.gif" wid&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8961772" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/avip/archive/tags/api/default.aspx">api</category><category domain="http://blogs.msdn.com/avip/archive/tags/architecture/default.aspx">architecture</category><category domain="http://blogs.msdn.com/avip/archive/tags/programming/default.aspx">programming</category></item><item><title>Code commenting? Try Business Commenting.</title><link>http://blogs.msdn.com/avip/archive/2008/07/25/code-commenting-try-business-commenting.aspx</link><pubDate>Fri, 25 Jul 2008 06:12:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8770984</guid><dc:creator>Avi Pilosof</dc:creator><slash:comments>16</slash:comments><comments>http://blogs.msdn.com/avip/comments/8770984.aspx</comments><wfw:commentRss>http://blogs.msdn.com/avip/commentrss.aspx?PostID=8770984</wfw:commentRss><wfw:comment>http://blogs.msdn.com/avip/rsscomments.aspx?PostID=8770984</wfw:comment><description>&lt;p&gt;Jeff has a good post here about code comments and that they shouldn't be used as crutches:&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.codinghorror.com/blog/archives/001150.html"&gt;Coding Horror: Coding Without Comments&lt;/a&gt;&lt;/p&gt; &lt;p&gt;I agree with the article, but one thing I rarely hear mentioned is that it's often more interesting to comment the business justification than it is to comment the code. Jeff goes some way towards suggesting this when he says to comment the "why", but for many people that translates to "Why did I write the &lt;em&gt;code&lt;/em&gt; this way?".&lt;/p&gt; &lt;p&gt;I often find that code I'm maintaining is missing comments regarding the business logic. Rather than "Why is the code designed like this?", something like "Why is the business process designed like this?"&lt;/p&gt; &lt;p&gt;This becomes most useful when you look at unfamiliar code (your own, probably) and decide that the easily-digestible code is nevertheless doing something you are sure is silly, and you change it. Big mistake.&lt;/p&gt; &lt;p&gt;Example of a code architecture comment:&lt;/p&gt; &lt;div&gt; &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #008000"&gt;// We cache these values because they only change once per&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #008000"&gt;// week or so.&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Or:&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #008000"&gt;// We lazy-load these properties because they're rarely used&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #008000"&gt;// and they chew up a decent amount of RAM.&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Example of a business architecture comment:&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #008000"&gt;// We copy the lab owner on this mail because even though&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #008000"&gt;// they don't own this resource, they wanted to be aware&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #008000"&gt;// of changes. See bug 54321 for request and history.&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Or:&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #008000"&gt;// This used to delete items older than 30 days, but&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #008000"&gt;// bug #65432 requested that an exception be made for&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #008000"&gt;// items that are of type X.&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;All are useful, but I find the second type are rarely used. They become more valuable as the code ages.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Avi&lt;/p&gt;
&lt;p&gt;&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href="http://www.addthis.com/bookmark.php" onclick="window.open('http://www.addthis.com/bookmark.php?wt=nw&amp;pub=avip&amp;url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title), 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100'); return false;" title="Bookmark and Share" target="_blank"&gt;&lt;img src="http://s9.addthis.com/button1-share.gif" wid&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8770984" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/avip/archive/tags/programming/default.aspx">programming</category></item><item><title>Australia is going to France!</title><link>http://blogs.msdn.com/avip/archive/2008/07/08/australia-is-going-to-france.aspx</link><pubDate>Tue, 08 Jul 2008 03:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8705379</guid><dc:creator>Avi Pilosof</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/avip/comments/8705379.aspx</comments><wfw:commentRss>http://blogs.msdn.com/avip/commentrss.aspx?PostID=8705379</wfw:commentRss><wfw:comment>http://blogs.msdn.com/avip/rsscomments.aspx?PostID=8705379</wfw:comment><description>&lt;P&gt;(Bonus points for misleading title)&lt;/P&gt;
&lt;P&gt;The Australian &lt;A href="http://imaginecup.com/MyStuff/MyTeam.aspx?TeamID=12410" mce_href="http://imaginecup.com/MyStuff/MyTeam.aspx?TeamID=12410"&gt;Team SOAK&lt;/A&gt; just &lt;A href="http://blogs.msdn.com/msozacademic/archive/2008/07/07/wow-team-soak-advance-to-the-finals-at-imagine-cup.aspx" mce_href="http://blogs.msdn.com/msozacademic/archive/2008/07/07/wow-team-soak-advance-to-the-finals-at-imagine-cup.aspx"&gt;made it into the finals&lt;/A&gt; of the Imagine Cup. They were one of the 6 teams chosen in the Software Design Category.&lt;/P&gt;
&lt;P&gt;This year's theme was "The Environment", and Team SOAK has written software to monitor/control water usage on farms.&lt;/P&gt;
&lt;P&gt;Well done guys! I'll even forgive the fact you're from Melbourne ;)&lt;/P&gt;
&lt;P mce_keep="true"&gt;UPDATE: &lt;A class="" href="http://imaginecupfinalsinparis.spaces.live.com/blog/cns!3881675633140DB4!604.entry" mce_href="http://imaginecupfinalsinparis.spaces.live.com/blog/cns!3881675633140DB4!604.entry"&gt;They won!!!!&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Avi&lt;/P&gt;
&lt;P&gt;&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href="http://www.addthis.com/bookmark.php" onclick="window.open('http://www.addthis.com/bookmark.php?wt=nw&amp;pub=avip&amp;url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title), 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100'); return false;" title="Bookmark and Share" target="_blank"&gt;&lt;img src="http://s9.addthis.com/button1-share.gif" wid&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8705379" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/avip/archive/tags/programming/default.aspx">programming</category></item><item><title>It's all just a clock measuring contest...</title><link>http://blogs.msdn.com/avip/archive/2008/07/04/it-s-all-just-a-clock-measuring-contest.aspx</link><pubDate>Fri, 04 Jul 2008 01:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8685835</guid><dc:creator>Avi Pilosof</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/avip/comments/8685835.aspx</comments><wfw:commentRss>http://blogs.msdn.com/avip/commentrss.aspx?PostID=8685835</wfw:commentRss><wfw:comment>http://blogs.msdn.com/avip/rsscomments.aspx?PostID=8685835</wfw:comment><description>&lt;p&gt;Did you know that &lt;a href="http://groups.google.com/group/comp.lang.lisp/browse_frm/thread/25fb220a1da975fb#"&gt;SBCL is now faster than Java, as fast as Ocaml, and getting better&lt;/a&gt;?! What does this mean for you? Most likely, nothing.&lt;/p&gt; &lt;p&gt;They have &lt;a href="http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&amp;amp;lang=all"&gt;various benchmarks&lt;/a&gt; that are used to measure the speed of a language implementation; and I think it's a good thing - it keeps the &lt;em&gt;implementers &lt;/em&gt;honest, and I'm not crazy about wasting CPU cycles just because they're there.&lt;/p&gt; &lt;p&gt;However, these numbers remind me very strongly of the local CompuMart selling the 2.4GHz machine for 1.5x the price of the 2.0GHz machine and relying on the fact that customers have no idea that this will make exactly zero difference for most uses.&lt;/p&gt; &lt;p&gt;Why? Because pretty much all programs nowadays depend on more than just the CPU. They're competing for RAM, disk access and maybe even network. None of those are nearly as fast as the CPU, hence most often create a bottleneck.&lt;/p&gt; &lt;p&gt;Aside from this, it's very likely that the code you're writing will be more dramatically improved by tweaking &lt;em&gt;your&lt;/em&gt; algorithms than it would by changing the language.&lt;/p&gt; &lt;p&gt;Couple that with the unfortunate fact that most jobs won't allow you to just grab SBCL or OCaml because it happens to be at the top of the list today, and you're left with a measurement that has little real-world value.&lt;/p&gt; &lt;p&gt;What these measurements &lt;em&gt;are &lt;/em&gt;good for is preventing those who write the language implementations from getting too lazy. While I think that application programmers &lt;em&gt;should &lt;/em&gt;generally be spending CPU cycles to save lines of code, I don't necessarily believe the same for platform/language programmers.&lt;/p&gt; &lt;p&gt;Just don't look at this list and get too disheartened about your choice of language. Even if it &lt;em&gt;is &lt;/em&gt;Ruby ;)&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Avi&lt;/p&gt; &lt;p&gt;&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href="http://www.addthis.com/bookmark.php" onclick="window.open('http://www.addthis.com/bookmark.php?wt=nw&amp;pub=avip&amp;url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title), 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100'); return false;" title="Bookmark and Share" target="_blank"&gt;&lt;img src="http://s9.addthis.com/button1-share.gif" wid&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8685835" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/avip/archive/tags/architecture/default.aspx">architecture</category><category domain="http://blogs.msdn.com/avip/archive/tags/programming/default.aspx">programming</category></item><item><title>Can Software be Reliable?</title><link>http://blogs.msdn.com/avip/archive/2008/06/27/can-software-be-reliable.aspx</link><pubDate>Fri, 27 Jun 2008 09:21:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8660252</guid><dc:creator>Avi Pilosof</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/avip/comments/8660252.aspx</comments><wfw:commentRss>http://blogs.msdn.com/avip/commentrss.aspx?PostID=8660252</wfw:commentRss><wfw:comment>http://blogs.msdn.com/avip/rsscomments.aspx?PostID=8660252</wfw:comment><description>&lt;p&gt;Just read &lt;a href="http://metaphorcrash.blogspot.com/"&gt;a post&lt;/a&gt; (permalink is broken) regarding how software engineering is nowhere near the level of quality as traditional engineering, partially because we don't have standards, regulations, etc.&lt;/p&gt; &lt;p&gt;While I agree with some of the argument, people often give too much credit to &lt;a href="http://en.wikipedia.org/wiki/Meatspace"&gt;meatspace&lt;/a&gt; engineering when compared to software.&lt;/p&gt; &lt;p&gt;You often get what you pay for, and this applies to both types of engineering. Look at &lt;a href="http://www.fastcompany.com/node/28121/print"&gt;NASA's software engineering team&lt;/a&gt; (&lt;em&gt;awesome&lt;/em&gt; article). Two quotes from there:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;"The last three versions of the program - each 420,000 lines long - had just one error each. The last 11 versions of this software had a total of 17 errors. Commercial programs of equivalent complexity would have 5,000 errors."&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;And:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;"...the group's $35 million per year budget is a trivial slice of the NASA pie, but on a dollars-per-line basis, it makes the group among the nation's most expensive software organizations."&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Similarly, there's other very reliable software running very reliable systems (nuclear reactors, chemical factories, fighter jets, stock markets, whatever). Basically, when you're prepared to pay for software quality, you &lt;em&gt;can get it&lt;/em&gt;.&lt;/p&gt; &lt;p&gt;Viewing things from the opposite direction; while it's true that none of my cars have ever spontaneously combusted on the highway, neither have any of them been bug free. There are always rattles, electrical problems, mechanical problems, and they all need constant maintenance - I can't treat my car recklessly and expect it to behave well forever. Just like with software, environmental changes can bring out defects in the original design. Bridges need constant maintenance, cracks form in buildings, roofs leak, gutters rust, foundations sink, water rises, dishwashers break (taking down my whole circuit) and light bulbs fry themselves.&lt;/p&gt; &lt;p&gt;Most of these things can be avoided with the judicious application of more resources (read: money [=time]). It just happens that most software companies get a better return on investment spending that money on new features/products than they do on aiming for &lt;a href="http://en.wikipedia.org/wiki/Five_nines"&gt;five nines&lt;/a&gt;. Why? Because that's generally what customers respond to. What would you prefer - an iPhone with Safari occasionally crashing, or that small Ericsson from 1997 that never &lt;em&gt;ever&lt;/em&gt; crashed?.&lt;/p&gt; &lt;p&gt;Sometimes it makes sense to spend a fortune to get that extra 1% (10%?) of quality, but each percent costs more than the last. I certainly want that last percent on bridges, airplanes and skyscrapers. But if I had to pay 3x the price for my video card (or phone, or DVD player) and wait 3x as long for new versions, I don't think it would be worth it.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Avi&lt;/p&gt; &lt;p&gt;&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href="http://www.addthis.com/bookmark.php" onclick="window.open('http://www.addthis.com/bookmark.php?wt=nw&amp;pub=avip&amp;url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title), 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100'); return false;" title="Bookmark and Share" target="_blank"&gt;&lt;img src="http://s9.addthis.com/button1-share.gif" wid&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8660252" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/avip/archive/tags/architecture/default.aspx">architecture</category><category domain="http://blogs.msdn.com/avip/archive/tags/programming/default.aspx">programming</category></item></channel></rss>