<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>uglycode</title>
	<atom:link href="http://uglycode.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://uglycode.wordpress.com</link>
	<description>All code is ugly. Some code is just less uglier than other code</description>
	<lastBuildDate>Mon, 31 Aug 2009 17:29:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='uglycode.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>uglycode</title>
		<link>http://uglycode.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://uglycode.wordpress.com/osd.xml" title="uglycode" />
	<atom:link rel='hub' href='http://uglycode.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Using an Event Aggregator from StoryTeller</title>
		<link>http://uglycode.wordpress.com/2009/08/12/using-an-event-aggregator-from-storyteller/</link>
		<comments>http://uglycode.wordpress.com/2009/08/12/using-an-event-aggregator-from-storyteller/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 08:57:19 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[EDA]]></category>
		<category><![CDATA[Event Driven Architecture]]></category>

		<guid isPermaLink="false">http://uglycode.wordpress.com/2009/08/12/using-an-event-aggregator-from-storyteller/</guid>
		<description><![CDATA[The StoryTeller aggregator utilizes two ways to get published events to the listeners. The first requires creating listeners that implement an &#160;&#160;&#160; public interface IListener&#60;T&#62; &#160;&#160;&#160; { &#160;&#160;&#160;&#160;&#160;&#160;&#160; void Handle(T message); &#160;&#160;&#160; } &#160; Publishing events requires using void SendMessage&#60;T&#62;(T message); &#160; Setting up an event handler (listeners is pretty easy. Just implement the interface [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglycode.wordpress.com&amp;blog=7947598&amp;post=33&amp;subd=uglycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The StoryTeller aggregator utilizes two ways to get published events to the listeners. The first requires creating listeners that implement an</p>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">interface</span> <span style="color:#2b91af;">IListener</span>&lt;T&gt;</p>
<p style="margin:0;">&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">void</span> Handle(T message);</p>
<p style="margin:0;">&#160;&#160;&#160; }</p>
</p></div>
<div id="codeSnippetWrapper">&#160;</div>
<div>Publishing events requires using</div>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<p style="margin:0;"><span style="color:blue;"></span></p>
<p style="margin:0;"><span style="color:blue;">void</span> SendMessage&lt;T&gt;(T message);</p>
</p></div>
<div id="codeSnippetWrapper">&#160;</div>
<div>Setting up an event handler (listeners is pretty easy. Just implement the interface for the class. If you are using ReSharper, You get code generation for free.</div>
<p>The second way is to supply a specific listener object when you send a message. I removed this method from the aggregator because it would not allow me to use an Action&lt;T&gt; signature message. </p>
<p>I extracted the event aggregator from StoryTeller to use as the messaging system for my new application. Since I didn’t have that much experience with this type of pattern, I needed some feedback for the application. </p>
<p>The feedback that I was interested in was the wiring of the events and there cascading effects when the events are activated. Pretty much this creates an event workflow.</p>
<p>The events used in the aggregator are push events. You load the event with data then publish the event. The events initially seem to be weak, There isn’t much to them except for the classes them selves.</p>
<p>More still to come…</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglycode.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglycode.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglycode.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglycode.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglycode.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglycode.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglycode.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglycode.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglycode.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglycode.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglycode.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglycode.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglycode.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglycode.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglycode.wordpress.com&amp;blog=7947598&amp;post=33&amp;subd=uglycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglycode.wordpress.com/2009/08/12/using-an-event-aggregator-from-storyteller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
		<item>
		<title>Extension Methods or a Closure: Why Not Both?</title>
		<link>http://uglycode.wordpress.com/2009/08/11/extension-methods-or-a-closure-why-not-both/</link>
		<comments>http://uglycode.wordpress.com/2009/08/11/extension-methods-or-a-closure-why-not-both/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 03:57:39 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[exetensions]]></category>
		<category><![CDATA[lamda]]></category>
		<category><![CDATA[closures]]></category>
		<category><![CDATA[extensions]]></category>

		<guid isPermaLink="false">http://uglycode.wordpress.com/2009/08/11/extension-methods-or-a-closure-why-not-both/</guid>
		<description><![CDATA[Lambdas can be useful for creating little utilities that can help you create more readable code. An example of creating an abstraction. &#160;&#160;&#160;&#160;&#160;&#160;&#160; [Test] &#160;&#160;&#160;&#160;&#160;&#160;&#160; public void should_use_classes_instead_of_better_stuff() &#160;&#160;&#160;&#160;&#160;&#160;&#160; { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Looper.Loop(5, new Printer()); &#160;&#160;&#160;&#160;&#160;&#160;&#160; } &#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160; public class Looper &#160;&#160;&#160;&#160;&#160;&#160;&#160; { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; public static void Loop(int count, Printer print) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; const [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglycode.wordpress.com&amp;blog=7947598&amp;post=30&amp;subd=uglycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Lambdas can be useful for creating little utilities that can help you create more readable code. An example of creating an abstraction.</p>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; [<span style="color:#2b91af;">Test</span>]</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">void</span> should_use_classes_instead_of_better_stuff()</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">Looper</span>.Loop(5, <span style="color:blue;">new</span> <span style="color:#2b91af;">Printer</span>());</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">Looper</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> Loop(<span style="color:blue;">int</span> count, <span style="color:#2b91af;">Printer</span> print)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">const</span> <span style="color:blue;">int</span> max_count = 5;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">for</span> (<span style="color:blue;">int</span> i = 0; i &lt; max_count; i++)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; print.Output();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">Printer</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">void</span> Output()</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">&quot;Executing&quot;</span>);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</p></div>
<div>&#160;</div>
<div>Output</div>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<p style="margin:0;">Executing</p>
<p style="margin:0;">Executing</p>
<p style="margin:0;">Executing</p>
<p style="margin:0;">Executing</p>
<p style="margin:0;">Executing</p>
</p></div>
<div id="codeSnippetWrapper">&#160;</div>
<div>As you can see a lot of work just to print out “Executing” string, and you may run into having to make a changes into your classes.</div>
<div>&#160;</div>
<div>Let’s say the string printed to the console needs to change like this.</div>
<div>&#160;</div>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; [<span style="color:#2b91af;">Test</span>]</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">void</span> should_use_classes_instead_of_better_stuff()</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">Looper</span>.Loop(1, <span style="color:blue;">new</span> <span style="color:#2b91af;">Printer</span>(<span style="color:#a31515;">&quot;Start&quot;</span>));</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">Looper</span>.Loop(5, <span style="color:blue;">new</span> <span style="color:#2b91af;">Printer</span>(<span style="color:#a31515;">&quot;Middle&quot;</span>));</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">Looper</span>.Loop(1, <span style="color:blue;">new</span> <span style="color:#2b91af;">Printer</span>(<span style="color:#a31515;">&quot;End&quot;</span>));</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</p></div>
<div>&#160;</div>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">Looper</span></p>
<p style="margin:0;">&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> Loop(<span style="color:blue;">int</span> max_count, <span style="color:#2b91af;">Printer</span> print)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">for</span> (<span style="color:blue;">int</span> i = 0; i &lt; max_count; i++)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; print.Output();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">Printer</span></p>
<p style="margin:0;">&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">private</span> <span style="color:blue;">readonly</span> <span style="color:blue;">string</span> _prefix;</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> Printer(<span style="color:blue;">string</span> prefix)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _prefix = prefix;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">void</span> Output()</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">&quot;{0} Executing&quot;</span>, _prefix);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160; }</p>
</p></div>
<div>Output</div>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<p style="margin:0;">Start Executing</p>
<p style="margin:0;">Middle Executing</p>
<p style="margin:0;">Middle Executing</p>
<p style="margin:0;">Middle Executing</p>
<p style="margin:0;">Middle Executing</p>
<p style="margin:0;">Middle Executing</p>
<p style="margin:0;">End Executing</p>
</p></div>
<div>&#160;</div>
<div>Now let’s get into using closures.&#160; </div>
<div>&#160;</div>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; [<span style="color:#2b91af;">Test</span>]</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">void</span> should_use_closures()</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">Action</span>&lt;<span style="color:blue;">string</span>&gt; print = (prefix =&gt; <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">&quot;{0} Executing&quot;</span>, prefix));</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">Action</span>&lt;<span style="color:blue;">int</span>, <span style="color:#2b91af;">Action</span>&gt; loop = ((count, fn) =&gt;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">for</span> (<span style="color:blue;">int</span> i = 0; i &lt; count; i++)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; fn();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; loop(1, () =&gt; print(<span style="color:#a31515;">&quot;Start&quot;</span>));</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; loop(5, () =&gt; print(<span style="color:#a31515;">&quot;Middle&quot;</span>));</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; loop(1, () =&gt; print(<span style="color:#a31515;">&quot;End&quot;</span>));</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</p></div>
<div id="codeSnippetWrapper">&#160;</div>
<div>Output is the same as above.</div>
<div>&#160;</div>
<div>It still is a little noisy in the parameter for print. So let’s clean this up.</div>
<div>&#160;</div>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; [<span style="color:#2b91af;">Test</span>]</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">void</span> should_use_binding_lambda()</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">Action</span>&lt;<span style="color:blue;">string</span>&gt; print = (prefix =&gt; <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">&quot;{0} Executing&quot;</span>, prefix));</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">Action</span>&lt;<span style="color:blue;">int</span>, <span style="color:#2b91af;">Action</span>&gt; loop = ((count, fn) =&gt;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">for</span> (<span style="color:blue;">int</span> i = 0; i &lt; count; i++)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; fn();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">Func</span>&lt;<span style="color:blue;">string</span>, <span style="color:#2b91af;">Action</span>&gt; use_printer = (prefix =&gt; () =&gt; print(prefix));</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; loop(1, use_printer(<span style="color:#a31515;">&quot;Start&quot;</span>));</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; loop(5, use_printer(<span style="color:#a31515;">&quot;Middle&quot;</span>));</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; loop(1, use_printer(<span style="color:#a31515;">&quot;End&quot;</span>));</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</p></div>
<div id="codeSnippetWrapper">&#160;</div>
<div>This is nice abstraction. It hides the for loop from the programmer.</div>
<p>It still is noisy. How can we clean this up. TADA! Extension to the rescue.</p>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> Times(<span style="color:blue;">this</span> <span style="color:blue;">int</span> count, <span style="color:#2b91af;">Action</span> function)</p>
<p style="margin:0;">&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">for</span> (<span style="color:blue;">int</span> i = 0; i &lt; count; i++)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; function();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160; }</p>
</p></div>
<p>And the actual usage</p>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<p style="margin:0;">[<span style="color:#2b91af;">Test</span>]</p>
<p style="margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">void</span> should_use_binding_lambda_and_extension()</p>
<p style="margin:0;">{</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:#2b91af;">Action</span>&lt;<span style="color:blue;">string</span>&gt; print = (prefix =&gt; <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">&quot;{0} Executing&quot;</span>, prefix));</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:#2b91af;">Action</span>&lt;<span style="color:blue;">int</span>, <span style="color:#2b91af;">Action</span>&gt; loop = ((count, fn) =&gt;</p>
<p style="margin:0;">&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">for</span> (<span style="color:blue;">int</span> i = 0; i &lt; count; i++)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; fn();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160; });</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:#2b91af;">Func</span>&lt;<span style="color:blue;">string</span>, <span style="color:#2b91af;">Action</span>&gt; use_printer = (prefix =&gt; () =&gt; print(prefix));</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160; 1.Times(use_printer(<span style="color:#a31515;">&quot;Start&quot;</span>));</p>
<p style="margin:0;">&#160;&#160;&#160; 5.Times(use_printer(<span style="color:#a31515;">&quot;Middle&quot;</span>));</p>
<p style="margin:0;">&#160;&#160;&#160; 1.Times(use_printer(<span style="color:#a31515;">&quot;End&quot;</span>));</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">}</p>
</p></div>
<div id="codeSnippetWrapper">&#160;</div>
<div>Usage for all 4 iterations</div>
<div>&#160;</div>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<p style="margin:0;"><span style="color:green;">// class objects</span></p>
<p style="margin:0;"><span style="color:#2b91af;">Looper</span>.Loop(5, <span style="color:blue;">new</span> <span style="color:#2b91af;">Printer</span>(<span style="color:#a31515;">&quot;Middle&quot;</span>));</p>
<p style="margin:0;"><span style="color:green;">//closure</span></p>
<p style="margin:0;">loop(5, () =&gt; print(<span style="color:#a31515;">&quot;Middle&quot;</span>));</p>
<p style="margin:0;"><span style="color:green;">//binding on lambda</span></p>
<p style="margin:0;">loop(5, use_printer(<span style="color:#a31515;">&quot;Middle&quot;</span>));</p>
<p style="margin:0;"><span style="color:green;">//extension</span></p>
<p style="margin:0;">5.Times(use_printer(<span style="color:#a31515;">&quot;Middle&quot;</span>));</p>
</p></div>
<div id="codeSnippetWrapper">&#160;</div>
<div>Now which one would you use?</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglycode.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglycode.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglycode.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglycode.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglycode.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglycode.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglycode.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglycode.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglycode.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglycode.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglycode.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglycode.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglycode.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglycode.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglycode.wordpress.com&amp;blog=7947598&amp;post=30&amp;subd=uglycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglycode.wordpress.com/2009/08/11/extension-methods-or-a-closure-why-not-both/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
		<item>
		<title>Using lambdas for handling change</title>
		<link>http://uglycode.wordpress.com/2009/08/09/using-lambdas-for-handling-change/</link>
		<comments>http://uglycode.wordpress.com/2009/08/09/using-lambdas-for-handling-change/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 00:58:00 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[lamda]]></category>
		<category><![CDATA[lambda]]></category>

		<guid isPermaLink="false">http://uglycode.wordpress.com/2009/08/09/using-lambdas-for-handling-change/</guid>
		<description><![CDATA[I was TDDing an Event Logger. Now the logger takes an event message and then adds a date time stamp. The way you would do it is use DateTime.Now. The problem was how to verify that the date time stamp had been added. Pass into the object a DateTimeServer object. This seemed too much. Create [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglycode.wordpress.com&amp;blog=7947598&amp;post=23&amp;subd=uglycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was TDDing an Event Logger. Now the logger takes an event message and then adds a date time stamp. The way you would do it is use DateTime.Now. The problem was how to verify that the date time stamp had been added. Pass into the object a DateTimeServer object. This seemed too much. Create an object. Talk about noisy tests. Instead I just pass this object into my logger and here is some some of the logger code:</p>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; [<span style="color:#2b91af;">Test</span>]</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">void</span> should_add_date_time_stamps()</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">const</span> <span style="color:blue;">string</span> dts = <span style="color:#a31515;">&quot;mm/dd/yyyy 00:00:00 AM&quot;</span>;</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">Func</span>&lt;<span style="color:blue;">string</span>&gt; dateTimeStamper = (() =&gt; dts);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">var</span> logger = <span style="color:blue;">new</span> EventLogger(dateTimeStamper);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; logger.Handle(OperationEstop.EStop);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; logger.Handle(OperationEstop.EStop);</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; logger.Data().ShouldContainForEachLine(dts);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; logger.Data().Lines().ShouldEqual(2);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</p></div>
<p>Notice in the test ShouldContainForEachLine and Lines methods. These are extension methods. They make the test much more readable.</p>
<div style="font-family:courier new;background:#e5e5e5;color:black;font-size:8pt;">
<pre style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">EventLogger</span> : <span style="color:#2b91af;">IListener</span>&lt;<span style="color:#2b91af;">OperationEstop</span>&gt;, </pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">IListener</span>&lt;<span style="color:#2b91af;">StatusMessage</span>&gt;, <span style="color:#2b91af;">IListener</span>&lt;<span style="color:#2b91af;">LoginSuccessful</span>&gt;,</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">IListener</span>&lt;<span style="color:#2b91af;">LoginEvent</span>&gt;, <span style="color:#2b91af;">IListener</span>&lt;<span style="color:#2b91af;">ScheduleLoad</span>&gt;,</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">IListener</span>&lt;<span style="color:#2b91af;">ScheduleLoadEvent</span>&gt;, <span style="color:#2b91af;">IListener</span>&lt;<span style="color:#2b91af;">SystemEvent</span>&gt;</pre>
<pre style="margin:0;">&#160;&#160;&#160; {</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">private</span> <span style="color:blue;">readonly</span> <span style="color:#2b91af;">StringBuilder</span> _sb = <span style="color:blue;">new</span> <span style="color:#2b91af;">StringBuilder</span>();</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">private</span> <span style="color:blue;">readonly</span> <span style="color:#2b91af;">Func</span>&lt;<span style="color:blue;">string</span>&gt; _dateTimeStamp;</pre>
<pre style="margin:0;">&#160;</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> EventLogger(<span style="color:#2b91af;">Func</span>&lt;<span style="color:blue;">string</span>&gt; stamp)</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _dateTimeStamp = stamp;</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</pre>
<pre style="margin:0;">&#160;</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">string</span> Data()</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">return</span> _sb.ToString();</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</pre>
<pre style="margin:0;">&#160;</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">void</span> Handle(<span style="color:#2b91af;">OperationEstop</span> message)</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; AddDateTimeStampToEntry(message.Status());</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</pre>
<pre style="margin:0;">&#160;</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">//Other Handlers ...</span></pre>
<pre style="margin:0;">&#160;</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">private</span> <span style="color:blue;">void</span> AddDateTimeStampToEntry(<span style="color:blue;">string</span> status)</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">if</span> (_sb.Length &gt; 0)</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _sb.AppendLine();</pre>
<pre style="margin:0;">&#160;</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; _sb.AppendFormat(<span style="color:#a31515;">&quot;{0} {1}&quot;</span>, _dateTimeStamp(), status.Trim());</pre>
<pre style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</pre>
<pre style="margin:0;">&#160;&#160;&#160; }</pre>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglycode.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglycode.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglycode.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglycode.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglycode.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglycode.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglycode.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglycode.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglycode.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglycode.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglycode.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglycode.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglycode.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglycode.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglycode.wordpress.com&amp;blog=7947598&amp;post=23&amp;subd=uglycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglycode.wordpress.com/2009/08/09/using-lambdas-for-handling-change/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
		<item>
		<title>What is my F***N&#8217; Domain</title>
		<link>http://uglycode.wordpress.com/2009/07/31/what-is-my-fn-domain/</link>
		<comments>http://uglycode.wordpress.com/2009/07/31/what-is-my-fn-domain/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 03:44:48 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[embedded systems]]></category>
		<category><![CDATA[event sourcing]]></category>
		<category><![CDATA[program design]]></category>

		<guid isPermaLink="false">http://uglycode.wordpress.com/?p=11</guid>
		<description><![CDATA[Right now there are some things at the bottom of my what the hell do I want to learn. What follows is not. I was grazing Ayende&#8216;s (unconfirmed AI System) blog. He&#8217;s starting some posts on developing  software in a domain he knows. For the last year I&#8217;ve been working on stretching my horizons. Specifically [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglycode.wordpress.com&amp;blog=7947598&amp;post=11&amp;subd=uglycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Right now there are some things at the bottom of my what the hell do I want to learn. What follows is not.</p>
<p>I was grazing <a href="http://feedproxy.google.com/~r/AyendeRahien/~3/6DnA47I2_Zs/more-on-macto.aspx">Ayende</a>&#8216;s (unconfirmed AI System) blog. He&#8217;s starting some posts on developing  software in a domain he knows.</p>
<p>For the last year I&#8217;ve been working on stretching my horizons. Specifically trying to learn how to be a <a href="http://uglylispcode.wordpress.com/">real hacker</a> <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . I need to write about what I know.</p>
<p>My domain is automatic equipment for manufacturing electronics. Motion control, vision systems, power supplies as welders, and environmental enclosures</p>
<p>So I&#8217;m going to write software for a Pick and Place System. As development occurs we will be adding software features, mechanical and electrical devices. The key for us is that we are going to do this without any actual hardware. I believe if you check out <a href="http://www.objectmentor.com/resources/articles/ProgressBeforeHardware.pdf"><em>Progress Before Hardware</em></a> you will see how were going to try to do this.</p>
<p><span id="more-11"></span>As experience tells me when working with automation, a basic system is never enough. Manufacturers can deal with this various ways. One is, <a href="http://en.wikiquote.org/wiki/Henry_Ford"><strong>Any customer can have a car painted any colour that he wants so long as it is black.</strong></a> Just starting out this can be a good business model, low costs. The major downside is lost sales.</p>
<p>A second is, to have a third party, a system integrator, design and implement the add-on for you. This can have a very good upside if you don&#8217;t have the experience in dealing with this add-on. Having your own in-house engineers and technicians  involved with the systems integrator from the get-go can help you grow your own in-house experience. A plus is increased sales. A downside is lost revenue due to costs for system integration.</p>
<p>The third option is to give the customer what he wants and do it all in-house. The major downside is that you take on all the risk. Upside is that all the $$$REVENUE IS YOURS$$$. This is the option that we are going to follow.</p>
<p>We want to try and grow this system organically as we add all the additional features.</p>
<p>Some of the modules in no particular order:</p>
<ul>
<li>E-Stop System</li>
<li>Status Indicators</li>
<li>Manual Diagnostics</li>
<li>Logging</li>
<li>Statistics</li>
<li>Motion Control</li>
<li>Vision</li>
<li>And whatever we want to do</li>
</ul>
<p>A basic system will be</p>
<ul>
<li>E-Stop System</li>
<li>Manual Diagnostics</li>
<li>Logging</li>
<li>Motion Control</li>
</ul>
<p>One idea that I really want to accomplish with this is to use <a href="http://martinfowler.com/eaaDev/EventSourcing.html">Event Sourcing</a>. This would mean that we could reap huge benefits not only when we have to diagnose customer problems, but testing of our application much easier. This would make logging somewhat superflous don&#8217;t you think?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglycode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglycode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglycode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglycode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglycode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglycode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglycode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglycode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglycode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglycode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglycode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglycode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglycode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglycode.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglycode.wordpress.com&amp;blog=7947598&amp;post=11&amp;subd=uglycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglycode.wordpress.com/2009/07/31/what-is-my-fn-domain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
		<item>
		<title>Explorations in declarative programming</title>
		<link>http://uglycode.wordpress.com/2009/07/29/explorations-in-declaritve-programming/</link>
		<comments>http://uglycode.wordpress.com/2009/07/29/explorations-in-declaritve-programming/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 22:07:17 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[closures]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[EDA]]></category>

		<guid isPermaLink="false">http://uglycode.wordpress.com/?p=4</guid>
		<description><![CDATA[I want to explore the revolutionary idea of building software in a GPL (C#) that is declarative in style. This means using Event Driven Architecture, Internal DSLs, and Fluent Interfaces. If you check this out, you will see that I&#8217;m very passionate about what is happening in the software world. There is a revolution happening [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglycode.wordpress.com&amp;blog=7947598&amp;post=4&amp;subd=uglycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I want to explore the revolutionary idea of building software in a GPL (C#) that is declarative in style. This means using Event Driven Architecture, Internal DSLs, and Fluent Interfaces.</p>
<p>If you <a href="http://uglylispcode.wordpress.com/2009/07/26/ugly-lisp-code-compendium/">check this out</a>, you will see that I&#8217;m very passionate about what is happening in the software world. There is a revolution happening right now!</p>
<p>I don&#8217;t care what language you&#8217;re using today (including VB6). By following this blog maybe you and I can chart some of the revolution together.</p>
<p>Some things that were the impetuous for this blog post was these two blog posts.</p>
<h2><a href="http://codebetter.com/blogs/jeremy.miller/archive/2009/07/21/braindump-on-the-event-aggregator-pattern.aspx" target="_blank">[1] Braindump on the Event Aggregator Pattern</a></h2>
<h2><a href="http://jonathan-oliver.blogspot.com/2009/07/ddd-tdd-bdd-and-cqs.html" target="_blank">[2] DDD, TDD, BDD, and CQS</a></h2>
<p>[1] is a pretty concise description of the properties of an Event Aggregator (EA). The thing about EA is that it is more of a framework than a pattern. Something similar to an EA is <a href="http://www.cs.wustl.edu/~schmidt/PDF/Act-Obj.pdf">Active Object</a>. The key property for this is the decoupling of publisher from subscriber.</p>
<p>[2] Describes using a declarative language for interpreting systems with inputs, processors, and outputs. This interpretation uses a syntax of { When, Given, Then }. An example would be:</p>
<p>When some_input_event</p>
<p>Given this_process</p>
<p>Then some_output_event</p>
<p>This a declarative language.</p>
<p>&#8216;<a href="http://en.wikipedia.org/wiki/Convention_over_configuration">convention over configuration</a>&#8216; succinctly differentiates the declarative and imperative IMHO.</p>
<p>This exploration will utilize command patterns, events, message buses, computational systems, SRP, closures, decoupling, and you name it we&#8217;ll cover it.</p>
<p>Be sure to comment!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglycode.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglycode.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglycode.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglycode.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglycode.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglycode.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglycode.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglycode.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglycode.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglycode.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglycode.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglycode.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglycode.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglycode.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglycode.wordpress.com&amp;blog=7947598&amp;post=4&amp;subd=uglycode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglycode.wordpress.com/2009/07/29/explorations-in-declaritve-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
	</channel>
</rss>
