<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>James Crisp &#187; C#</title>
	<link>http://jamescrisp.org</link>
	<description>C#, JRuby, Ruby on Rails, .NET, book reviews, film reviews, mind hacks, Wing Chun and the occasional personal bit.</description>
	<pubDate>Sun, 06 Jul 2008 00:29:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.3</generator>
	<language>en</language>
			<item>
		<title>Bounded Actions Using Lambda - IDisposable is old and ugly!</title>
		<link>http://jamescrisp.org/2008/05/26/bounded-actions-using-lambda-idisposable-is-old-and-ugly/</link>
		<comments>http://jamescrisp.org/2008/05/26/bounded-actions-using-lambda-idisposable-is-old-and-ugly/#comments</comments>
		<pubDate>Mon, 26 May 2008 13:17:37 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[C#]]></category>

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

		<guid isPermaLink="false">http://jamescrisp.org/2008/05/26/bounded-actions-using-lambda-idisposable-is-old-and-ugly/</guid>
		<description><![CDATA[In .NET 2, it was all the rage to make hand-crafted, clever IDisposables that let you do a bounded action with clean up. Eg,

void SomeMethod()
{
        using (new SetCursorToWaitEggTimer())
        {
            VerySlowOperation();
 [...]]]></description>
			<content:encoded><![CDATA[<p>In .NET 2, it was all the rage to make hand-crafted, clever IDisposables that let you do a bounded action with clean up. Eg,</p>
<pre>
void SomeMethod()
{
        using (new SetCursorToWaitEggTimer())
        {
            VerySlowOperation();
        }
}

void VerySlowOperation()
{
    ... etc ...
}
</pre>
<p>This was kind of cute - you could make sure that, even if an exception was thrown, your clean up (eg, changing cursor back to normal) would occur. Implementing the IDisposable was a bit ugly but consuming it wasn&#8217;t bad.</p>
<p>Now, with the sexy C# 3 syntax, you can do something similar much more elegantly. Eg,</p>
<pre>
void SomeMethod()
{
       DoWithWaitEggTimer(VerySlowOperation);
}

void DoWithWaitEggTimer(Action action)
{
    try
    {
        Mouse.OverrideCursor = Cursors.Wait;
        action();
    }
    finally
    {
        Mouse.OverrideCursor = null;
    }
}
</pre>
<p>If you&#8217;re feeling like more adventures, you can also start passing these delegates around and injecting them. For example:</p>
<pre>
class SomeClass
{
    public Action<Action> RunSlowCode
    {
    	get { return runSlowCode ?? new Action<Action>(a => a.Invoke()); }
    	set { runSlowCode = value; }
    }
    Action<Action> runSlowCode;

    void DoSomethingSlow()
    {
         RunSlowCode(PullDataFromExternalSystem);
    }
}
</pre>
<p>This approach allows you to inject the delegate for what happens when slow code is run. So you could inject DoWithWaitEggTimer() or something new like DoWithWaitMessageDisplayedToUser(). Similarly, it could be used for unit testing or injecting between layers in your application.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2008/05/26/bounded-actions-using-lambda-idisposable-is-old-and-ugly/feed/</wfw:commentRss>
		</item>
		<item>
		<title>C# Default Access Modifier for Class Members - and drop that private habit!</title>
		<link>http://jamescrisp.org/2008/05/26/c-default-access-modifier-for-class-members-and-drop-that-private-habit/</link>
		<comments>http://jamescrisp.org/2008/05/26/c-default-access-modifier-for-class-members-and-drop-that-private-habit/#comments</comments>
		<pubDate>Mon, 26 May 2008 12:39:28 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[C#]]></category>

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

		<guid isPermaLink="false">http://jamescrisp.org/2008/05/26/c-default-access-modifier-for-class-members-and-drop-that-private-habit/</guid>
		<description><![CDATA[The default access modifier for the members of a C# class (eg, fields, methods, and properties) is &#8216;private&#8217;. As such, I recommend never using the redundant &#8216;private&#8217; keyword for class members. Leaving off the private nicely separates your privates from your public/inheritable interface in syntax highlighting. It also saves people having to read redundant code [...]]]></description>
			<content:encoded><![CDATA[<p>The default access modifier for the members of a C# class (eg, fields, methods, and properties) is &#8216;private&#8217;. As such, I recommend never using the redundant &#8216;private&#8217; keyword for class members. Leaving off the private nicely separates your privates from your public/inheritable interface in syntax highlighting. It also saves people having to read redundant code - you wouldn&#8217;t want your code to be full of un-needed casts, or redundant &#8216;this.&#8217; references, would you?</p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2008/05/26/c-default-access-modifier-for-class-members-and-drop-that-private-habit/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WPF Control Inheritance With Generics</title>
		<link>http://jamescrisp.org/2008/05/26/wpf-control-inheritance-with-generics/</link>
		<comments>http://jamescrisp.org/2008/05/26/wpf-control-inheritance-with-generics/#comments</comments>
		<pubDate>Mon, 26 May 2008 12:19:17 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[WPF]]></category>

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

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

		<guid isPermaLink="false">http://jamescrisp.org/2008/05/26/wpf-control-inheritance-with-generics/</guid>
		<description><![CDATA[Working in WPF is quite exciting - there&#8217;s a lot of new possibilities, especially with easy control composition, much improved binding and Expression Blend to make sexy interfaces. One of the things you&#8217;re likely to want to do though, when writing anything more than a toy application, is to have a base class for your [...]]]></description>
			<content:encoded><![CDATA[<p>Working in WPF is quite exciting - there&#8217;s a lot of new possibilities, especially with easy control composition, much improved binding and Expression Blend to make sexy interfaces. One of the things you&#8217;re likely to want to do though, when writing anything more than a toy application, is to have a base class for your UserControls or Windows, to share common functionality. It is also quite likely you will want to use generics in conjunction with control inheritance. With both the code behind, and the XAML, it&#8217;s not immediately obvious how to do generic inheritance. It is a bit fiddly to get going, and sometimes the errors are not helpful. Here&#8217;s a simple example that outlines how to bring it together.</p>
<p><br/></p>
<p><b>The base control</b></p>
<pre>
namespace WpfGenericsDemo
{
    public class BaseUserControl&lt;T&gt; : UserControl where T : IPresenter
    {
        public BaseUserControl()
        {
            ... various configurations ...
        }

         ... Awesome functionality to share ...
    }
}
</pre>
<p><br/></p>
<p><b>The child control code-behind</b></p>
<pre>
namespace WpfGenericsDemo
{
    public partial class ChildUserControl : BaseUserControl&lt;ChildPresenter&gt;
    {
        public ChildUserControl()
        {
            InitializeComponent();
        }

         ... More code ...
    }
}
</pre>
<p><br/></p>
<p><b>The child control XAML</b></p>
<pre>
&lt;WpfGenericsDemo:BaseUserControl x:Class="WpfGenericsDemo.ChildUserControl"
    x:TypeArguments="WpfGenericsDemo:ChildPresenter"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:WpfGenericsDemo="clr-namespace:WpfGenericsDemo"&gt;

    ... The rest of your awesome XAML ...

&lt;/WpfGenericsDemo:BaseUserControl&gt;
</pre>
<p><br/></p>
<p>
<b>Notes</b></p>
<ul>
<li>Your top level node is the parent class of the control you want to create (eg, BaseUserControl). You specify the control class you want to create with &#8216;x:class&#8217; (eg, ChildUserControl)</li>
<li>&#8216;x:TypeArguments&#8217; is the way you specify the generic type (eg, ChildPresenter)</li>
<li>You need to namespace your classes - eg, with &#8216;xmlns:WpfGenericsDemo&#8217; which uses a clr-namespace style reference</li>
<li>Only your top level node can be genericised in XAML</li>
<p><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2008/05/26/wpf-control-inheritance-with-generics/feed/</wfw:commentRss>
		</item>
		<item>
		<title>NUnit Test Runners Were Not All Made Equal</title>
		<link>http://jamescrisp.org/2008/04/08/nunit-test-runners-were-not-all-made-equal/</link>
		<comments>http://jamescrisp.org/2008/04/08/nunit-test-runners-were-not-all-made-equal/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 07:26:11 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[Testing]]></category>

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

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

		<guid isPermaLink="false">http://jamescrisp.org/2008/04/08/nunit-test-runners-were-not-all-made-equal/</guid>
		<description><![CDATA[NUnit tests can be run using a variety of different runners. Some common ones are:

NUnit GUI
Test Driven .NET
Resharper test runner
NUnit MS Build Task

The NUnit GUI and Test Driven create a new instance of the test class for each test run. This leads to more isolation but potentially slower performance.
Resharper and NUnit MSBuild Task re-use the [...]]]></description>
			<content:encoded><![CDATA[<p>NUnit tests can be run using a variety of different runners. Some common ones are:</p>
<ul>
<li><a href="http://www.nunit.org/">NUnit GUI</a></li>
<li><a href="http://www.testdriven.net/">Test Driven .NET</a></li>
<li><a href="http://www.jetbrains.com/resharper/">Resharper test runner</a></li>
<li><a href="http://msbuildtasks.tigris.org/">NUnit MS Build Task</a></li>
</ul>
<p>The NUnit GUI and Test Driven create a new instance of the test class for each test run. This leads to more isolation but potentially slower performance.</p>
<p>Resharper and NUnit MSBuild Task re-use the same instance of the test class when running each test in the class. This can lead to unintended interaction between tests. Using these runners, it is vital to to assign initial values to instance variables in SetUp, rather than when they are defined or in the constructor.</p>
<p>If you use a mix of different test runners, you can end up with tests that pass on some machines and fail on others (eg, Test Driven locally works fine, but you use NUnit MSBuild Task on your build box and get intermittent failures).</p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2008/04/08/nunit-test-runners-were-not-all-made-equal/feed/</wfw:commentRss>
		</item>
		<item>
		<title>NUnit SetUp Attribute and Subclassed Test Cases</title>
		<link>http://jamescrisp.org/2008/04/08/nunit-setup-attribute-and-subclassed-test-cases/</link>
		<comments>http://jamescrisp.org/2008/04/08/nunit-setup-attribute-and-subclassed-test-cases/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 07:05:44 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[Testing]]></category>

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

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

		<guid isPermaLink="false">http://jamescrisp.org/2008/04/08/nunit-setup-attribute-and-subclassed-test-cases/</guid>
		<description><![CDATA[If you have a ChildTestCase class that inherits from a ParentTestCase class, and both of these have a SetUp method, marked with the [SetUp] attribute, would you expect both to be called? If so, you would be sadly disappointed. Only the SetUp method of the ChildTestCase will be called, and the SetUp in the ParentTestCase [...]]]></description>
			<content:encoded><![CDATA[<p>If you have a ChildTestCase class that inherits from a ParentTestCase class, and both of these have a SetUp method, marked with the [SetUp] attribute, would you expect both to be called? If so, you would be sadly disappointed. Only the SetUp method of the ChildTestCase will be called, and the SetUp in the ParentTestCase will be ignored. </p>
<p>According to the <a href="http://www.nunit.org/index.php?p=setup&#038;r=2.2.10">NUnit documentation on the Set Up attribute</a>, this is intended behaviour:</p>
<blockquote><p>
If you wish to add more SetUp functionality in a derived class you need to mark the method with the appropriate attribute and then call the base class method.
</p></blockquote>
<p>An alternative approach to get all your SetUps called is to have a base TestCase class define a protected virtual SetUp() (with the SetUp attribute), which all child classes override (and call base on their first line).</p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2008/04/08/nunit-setup-attribute-and-subclassed-test-cases/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Delicious .NET - Slides &#038; Code</title>
		<link>http://jamescrisp.org/2007/10/04/delicious-net-slides-code/</link>
		<comments>http://jamescrisp.org/2007/10/04/delicious-net-slides-code/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 04:47:07 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[Talks]]></category>

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

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

		<guid isPermaLink="false">http://jamescrisp.org/2007/10/04/delicious-net-slides-code/</guid>
		<description><![CDATA[Here&#8217;s the slides and code from yesterday&#8217;s &#8220;Delicious Dot Net&#8221; talk at ACS.


  Powerpoint Presentation


  Delicious Server Code


  Delicious Client Code (online and offline)


  Microsoft samples



]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the slides and code from yesterday&#8217;s <a href="http://jamescrisp.org/2007/09/28/acs-talk-delicious-net-3rd-oct/">&#8220;Delicious Dot Net&#8221; talk at ACS</a>.</p>
<ul>
<li>
  <a href="/wordpress/wp-content/uploads/2007/10/DeliciousDotNet.ppt">Powerpoint Presentation</a>
</li>
<li>
  <a href="/wordpress/wp-content/uploads/2007/10/DeliciousServer.zip">Delicious Server Code</a>
</li>
<li>
  <a href="/wordpress/wp-content/uploads/2007/10/DeliciousClient.zip">Delicious Client Code (online and offline)</a>
</li>
<li>
  <a href="/wordpress/wp-content/uploads/2007/10/MicrosoftSamples.zip">Microsoft samples</a>
</li>
</ul>
<p><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2007/10/04/delicious-net-slides-code/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ACS Talk - &#8220;Delicious .NET&#8221; - 3rd Oct</title>
		<link>http://jamescrisp.org/2007/09/28/acs-talk-delicious-net-3rd-oct/</link>
		<comments>http://jamescrisp.org/2007/09/28/acs-talk-delicious-net-3rd-oct/#comments</comments>
		<pubDate>Fri, 28 Sep 2007 13:41:38 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[Talks]]></category>

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

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

		<guid isPermaLink="false">http://jamescrisp.org/2007/09/28/acs-talk-delicious-net-3rd-oct/</guid>
		<description><![CDATA[I&#8217;ll be giving a talk at an ACS event after work on Wed next week (3rd October). Here&#8217;s the blurb:
A tasty take on WPF, WCF, LINQ and O-R Mapping
An exploration of some of the freshest, tastiest and most powerful features in .NET 3.5 through implementing a useful application.
You&#8217;ll take away an understanding of what&#8217;s in [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be giving a talk at an ACS event after work on Wed next week (3rd October). Here&#8217;s the blurb:</p>
<p><b>A tasty take on WPF, WCF, LINQ and O-R Mapping</b></p>
<p>An exploration of some of the freshest, tastiest and most powerful features in .NET 3.5 through implementing a useful application.<br />
You&#8217;ll take away an understanding of what&#8217;s in .NET 3.5 and how to build online and offline applications with the new technology stack supported by Visual Studio 2008 (Orcas Beta 2). </p>
<p><b>Location</b><br />
Norman Selfe Room,<br />
Level 3,<br />
280 Pitt St Sydney (Sydney Mechanics School of Arts)</p>
<p><b>Time</b><br />
6:15pm, 3rd October 2007</p>
<p>For more info or to register, please visit the <a href="http://acs.org.au/index.cfm?action=event&#038;area=9001&#038;temID=eventdetails&#038;eveID=10082197413786">ACS site</a>.</p>
<p>Hope you can come <img src='http://jamescrisp.org/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2007/09/28/acs-talk-delicious-net-3rd-oct/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reflexil, cute code injection for C#</title>
		<link>http://jamescrisp.org/2007/09/27/reflexil-cute-code-injection-for-c/</link>
		<comments>http://jamescrisp.org/2007/09/27/reflexil-cute-code-injection-for-c/#comments</comments>
		<pubDate>Thu, 27 Sep 2007 07:20:42 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[C#]]></category>

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

		<guid isPermaLink="false">http://jamescrisp.org/2007/09/27/reflexil-cute-code-injection-for-c/</guid>
		<description><![CDATA[While catching up on my favourite blogs, I came across Reflexil on Fabrice&#8217;s blog. Reflexil is able to do C# code injection into existing assemblies and save the resulting assembly. I haven&#8217;t given it a go yet, but it looks like a really neat tool. The legal implications may mean it is only useful for [...]]]></description>
			<content:encoded><![CDATA[<p>While catching up on my favourite blogs, I came across <a href="http://sebastien.lebreton.free.fr/reflexil/">Reflexil</a> on <a href="http://weblogs.asp.net/fmarguerie/archive/2007/09/05/Reflexil-csharp-code-injection-in-assemblies.aspx">Fabrice&#8217;s blog</a>. Reflexil is able to do C# code injection into existing assemblies and save the resulting assembly. I haven&#8217;t given it a go yet, but it looks like a really neat tool. The legal implications may mean it is only useful for emergency patching or debugging however&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2007/09/27/reflexil-cute-code-injection-for-c/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BarCamp Sydney this Saturday</title>
		<link>http://jamescrisp.org/2007/08/22/barcamp-sydney-this-saturday/</link>
		<comments>http://jamescrisp.org/2007/08/22/barcamp-sydney-this-saturday/#comments</comments>
		<pubDate>Wed, 22 Aug 2007 12:09:05 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[JRuby]]></category>

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

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

		<category><![CDATA[Ruby / Rails]]></category>

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

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

		<guid isPermaLink="false">http://jamescrisp.org/2007/08/22/barcamp-sydney-this-saturday/</guid>
		<description><![CDATA[It is BarCamp in Sydney this Saturday. I haven&#8217;t been to one of these unconference style events before, but I&#8217;ve heard good things about it from my colleagues. I&#8217;m quite excited to go along and see what it is like. 
If you&#8217;re in Sydney and interested in stopping by, details are as follows:
When: Sat 25th [...]]]></description>
			<content:encoded><![CDATA[<p>It is <a href="http://barcampsydney.org/">BarCamp in Sydney</a> this Saturday. I haven&#8217;t been to one of these unconference style events before, but I&#8217;ve heard good things about it from my colleagues. I&#8217;m quite excited to go along and see what it is like. </p>
<p>If you&#8217;re in Sydney and interested in stopping by, details are as follows:</p>
<p><b>When:</b> Sat 25th August 2007 from about 9am<br />
<b>Where:</b> University of Technology, Sydney (Jones St entrance)<br />
<a href="http://barcampsydney.org/?page_id=4">More details&#8230;</a></p>
<p>One of the novel aspects of BarCamp is that all participants are encouraged to present or start a discussion around something that interests them. For my part, depending on what people are interested in, I was thinking of one of the following:</p>
<ul>
<li>new stuff in the .net space (C# 3.0, .NET 3.5, LINQ, WPF, WCF, etc) and showing some demos</li>
<li>giving a bit of a Ruby/JRuby introduction with help from <a href="http://ola-bini.blogspot.com/2007/08/my-presentation-from-javabin.html">Ola&#8217;s  JavaBin slides</a></li>
<li>or, if people are keen, a discussion around JRuby vs C# 3 vs Java vs ?? and their stacks for different situations and problems</li>
<ul>
<p>By the way, the conference is free, and it is not too late to sign up <img src='http://jamescrisp.org/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
Hope to see you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2007/08/22/barcamp-sydney-this-saturday/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Slides from &#8216;Learning to live with the static-typing fascist and the dynamic-typing fan-boy in your enterprise…&#8217;</title>
		<link>http://jamescrisp.org/2007/08/15/slides-from-learning-to-live-with-the-static-typing-fascist-and-the-dynamic-typing-fan-boy-in-your-enterprise%e2%80%a6/</link>
		<comments>http://jamescrisp.org/2007/08/15/slides-from-learning-to-live-with-the-static-typing-fascist-and-the-dynamic-typing-fan-boy-in-your-enterprise%e2%80%a6/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 02:03:13 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[Talks]]></category>

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

		<category><![CDATA[Ruby / Rails]]></category>

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

		<guid isPermaLink="false">http://jamescrisp.org/2007/08/15/slides-from-learning-to-live-with-the-static-typing-fascist-and-the-dynamic-typing-fan-boy-in-your-enterprise%e2%80%a6/</guid>
		<description><![CDATA[Here&#8217;s the slides from Jim&#8217;s and my recent presentation at Tech Ed 07 on the Gold Coast and in Auckland:
LearningToLiveWithTheStaticTypingFascistAndTheDynamicTypingFanboy-TechEd07.pptx  (Powerpoint 2007)
LearningToLiveWithTheStaticTypingFascistAndTheDynamicTypingFanboy-TechEd07.ppt (Powerpoint 2003)
You may also be interested in having a read of the abstract.
]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the slides from <a href="http://jim.webber.name">Jim</a>&#8217;s and my recent presentation at Tech Ed 07 on the Gold Coast and in Auckland:</p>
<p><a href='http://jamescrisp.org/wordpress/wp-content/uploads/2007/08/LearningToLiveWithTheStaticTypingFascistAndTheDynamicTypingFanboy-TechEd07.pptx' title='LearningToLiveWithTheStaticTypingFascistAndTheDynamicTypingFanboy-TechEd07.ptx'>LearningToLiveWithTheStaticTypingFascistAndTheDynamicTypingFanboy-TechEd07.pptx  (Powerpoint 2007)</a></p>
<p><a href='http://jamescrisp.org/wordpress/wp-content/uploads/2007/08/LearningToLiveWithTheStaticTypingFascistAndTheDynamicTypingFanboy-TechEd07.ppt' title='LearningToLiveWithTheStaticTypingFascistAndTheDynamicTypingFanboy-TechEd07.ppt'>LearningToLiveWithTheStaticTypingFascistAndTheDynamicTypingFanboy-TechEd07.ppt (Powerpoint 2003)</a></p>
<p>You may also be interested in having a read of the <a href="http://jamescrisp.org/2007/08/02/tech-ed-talks/">abstract</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2007/08/15/slides-from-learning-to-live-with-the-static-typing-fascist-and-the-dynamic-typing-fan-boy-in-your-enterprise%e2%80%a6/feed/</wfw:commentRss>
		</item>
		<item>
		<title>TechEd 07 - Some interesting snippets</title>
		<link>http://jamescrisp.org/2007/08/14/teched-07-some-interesting-snippets/</link>
		<comments>http://jamescrisp.org/2007/08/14/teched-07-some-interesting-snippets/#comments</comments>
		<pubDate>Mon, 13 Aug 2007 22:06:11 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[Ruby / Rails]]></category>

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

		<guid isPermaLink="false">http://jamescrisp.org/2007/08/14/teched-07-some-interesting-snippets/</guid>
		<description><![CDATA[Silverlight

Silverlight runs on MAC and PC.
There is now a CLR for the Mac.
Microsoft is not currently planning to provide Silverlight for any unix platform (although there is MoonLight).
Silverlight 1.0 is basically a media player. It has hooks for javascript etc and some might say it has similar functionality to the Flash movie player.
Silverlight 1.1 has [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Silverlight</strong></p>
<ul>
<li>Silverlight runs on MAC and PC.</li>
<li>There is now a CLR for the Mac.</li>
<li>Microsoft is not currently planning to provide Silverlight for any unix platform (although there is MoonLight).</li>
<li>Silverlight 1.0 is basically a media player. It has hooks for javascript etc and some might say it has similar functionality to the Flash movie player.</li>
<li>Silverlight 1.1 has the real programming API. All further Silverlight references are to 1.1.</li>
<li>Silverlight will do a (currently undefined) simplified subset of WPF.</li>
<li>Silverlight gives acess to DOM in the browser.</li>
<li>Currently, the alpha allows 1mb local storage per page. In future, the storage is probably going to be shared across a domain rather than on a page by page basis.</li>
<li>Silverlight provides the capability to open a file on disk for read to allow for file uploads etc.</li>
<li>Interop between JavaScript and hosted Silverlight app is quite easy.</li>
<li>Silverlight looks a bit fiddly to set up, requiring javascript and sometimes xaml bootstrap - but being improved.</li>
</ul>
<p><strong>Software Factories</strong></p>
<ul>
<li>Allow solution and project structures to be auto-generated based on wizards.</li>
<li>Can provide code snippets and some (often template-based) code auto-generation.</li>
<li>Comes with documentation in help files and some context specific stuff.</li>
<li>Can include GUI designers that generate code.</li>
<li>People can develop their own domain specific factories.</li>
</ul>
<p><strong>DSLs</strong><br />
Currently, Microsoft&#8217;s take on DSLs is GUI editors, not written language or code. At the Software Factories talk, a GUI tool in Visual Studio for drawing your business entities and relationships was billed as a DSL.</p>
<p><strong>Windows Workflow Foundation (WF)</strong></p>
<ul>
<li>Activity based with GUI designer for connecting and composing activities.</li>
<li>Custom activities and compositions can be developed and inherit from base classes.</li>
<li>Single threaded and mainly queue based, with some events sprinkled through.</li>
<li>Activities can reference data from other activities using a mechanism vaguely like data binding.</li>
<li>Hosted in the CLR, so can be part of a console app, ASP.NET, WinForms etc.</li>
<li>Handles pickling and reconstitution of long running activities.</li>
<li>Base Activity classes provide virtual hooks. Eg, &#8216;Execute&#8217; for doing the work, &#8216;Cancel&#8217;, and &#8216;Compensate&#8217; for handling rollback scenarios.
</ul>
<p><strong>New in the Enterprise Library 3.1</strong></p>
<ul>
<li>Validation Application Block: provides simple, attribute based property validation. Easy integration with standard ErrorProvider on WinForms and WebForms and WPF is possible. Looks ok but somewhat basic - don&#8217;t think it supports warnings for example. It has GUI tool support and also capability to specify related objects which need to be validated.</li>
<li>Policy Injection Application Block: provides aspect oriented programming (AOP) style coding using attributes. All new AOP objects need to be created using the block&#8217;s object factory. Looks useful - there is out of the box support for validation, caching and logging in AOP fashion.</li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2007/08/14/teched-07-some-interesting-snippets/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tech Ed Talks</title>
		<link>http://jamescrisp.org/2007/08/02/tech-ed-talks/</link>
		<comments>http://jamescrisp.org/2007/08/02/tech-ed-talks/#comments</comments>
		<pubDate>Thu, 02 Aug 2007 06:37:18 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[Talks]]></category>

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

		<category><![CDATA[Ruby / Rails]]></category>

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

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

		<guid isPermaLink="false">http://jamescrisp.org/2007/08/02/tech-ed-talks/</guid>
		<description><![CDATA[Jim Webber and I will be co-presenting at Tech Ed Australia and Tech Ed New Zealand this year. Here&#8217;s the low down:
Learning to live with the static-typing fascist and the dynamic-typing fan-boy in your enterprise&#8230; 
Gold Coast
Thursday 9 Aug
5pm - 6:15pm
Auckland
Tuesday 14 Aug
2:20pm - 3:35pm
&#8220;What&#8217;s best for your enterprise? Is it the &#8216;glue that never [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jim.webber.name">Jim Webber</a> and I will be co-presenting at <a href="https://aunz.msteched.com/public/ausessions.aspx">Tech Ed Australia</a> and <a href="https://aunz.msteched.com/public/nzsessions.aspx">Tech Ed New Zealand</a> this year. Here&#8217;s the low down:</p>
<div style="border-left: 2px solid grey; margin-left: 2px; padding-left: 5px;"><strong>Learning to live with the static-typing fascist and the dynamic-typing fan-boy in your enterprise&#8230; </strong></p>
<p><em>Gold Coast</em><br />
Thursday 9 Aug<br />
5pm - 6:15pm</p>
<p><em>Auckland</em><br />
Tuesday 14 Aug<br />
2:20pm - 3:35pm</p>
<p>&#8220;What&#8217;s best for your enterprise? Is it the &#8216;glue that never sets&#8217; and flexibility of dynamic languages like Ruby, or the tried and true, hard and fast rules and tool support of static languages like C# 3.0? Are there different trade-offs for green field development and integration?</p>
<p>And more importantly, which is best, the Mac or PC?</p>
<p>In a dynamic, and combative presentation, Jim and James will let their alter-egos run amok and answer these questions from the perspective of a seasoned enterprise architect and a l33t hax0r. By the end of this session you will understand the interplays between the two personality types, have had a few laughs, and picked up a few tips on how to use both technology<br />
sets in harmony in your enterprise. &#8220;</p></div>
<p>Hope to see you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2007/08/02/tech-ed-talks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Castle Project - Rails for .NET</title>
		<link>http://jamescrisp.org/2007/06/12/the-castle-project-rails-for-net/</link>
		<comments>http://jamescrisp.org/2007/06/12/the-castle-project-rails-for-net/#comments</comments>
		<pubDate>Tue, 12 Jun 2007 13:26:00 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[Ruby / Rails]]></category>

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

		<guid isPermaLink="false">http://jamescrisp.org/wordpress/?p=61</guid>
		<description><![CDATA[The Castle Project is an interesting open source alternative to ASP.NET / ADO.NET. Among other things, the Castle Project provides a Rails-like development framework for .NET. It has an ActiveRecord implementation built on top of NHibernate, a very Rails-like MVC setup called MonoRail, and uses NVelocity for template style views. It&#8217;s worth checking out. This [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.castleproject.org/">The Castle Project</a> is an interesting open source alternative to ASP.NET / ADO.NET. Among other things, the Castle Project provides a <a href="http://www.rubyonrails.org/">Rails</a>-like development framework for .NET. It has an ActiveRecord implementation built on top of <a href="http://www.nhibernate.org/">NHibernate</a>, a very Rails-like MVC setup called MonoRail, and uses <a href="http://nvelocity.sourceforge.net/">NVelocity</a> for template style views. It&#8217;s worth checking out. This <a href="http://hammett.castleproject.org/wp-content/uploads/2007/01/mr%20formvalidation.html">screencast</a> gives a bit of an overview.</p>
<p>There&#8217;s tough competition around the corner though, with <a href="http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx">Orcas already in beta</a>, providing XAML, LINQ and O-R mapping.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2007/06/12/the-castle-project-rails-for-net/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Is .NET or Java dying?</title>
		<link>http://jamescrisp.org/2007/06/05/is-net-or-java-dying/</link>
		<comments>http://jamescrisp.org/2007/06/05/is-net-or-java-dying/#comments</comments>
		<pubDate>Tue, 05 Jun 2007 09:52:00 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[Java]]></category>

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

		<category><![CDATA[Ruby / Rails]]></category>

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

		<guid isPermaLink="false">http://jamescrisp.org/wordpress/?p=60</guid>
		<description><![CDATA[Are C# and .NET losing ground as Martin Fowler suggests? Or is Java&#8217;s market share dropping? What about Ruby? And what about the Australian market in particular?
Here&#8217;s what I&#8217;ve been able to find.
Job Trends
Which technologies have the most demand for people?
From Indeed.com, which claims to search &#8220;millions of jobs from thousands of job sites&#8221;, but [...]]]></description>
			<content:encoded><![CDATA[<p>Are C# and .NET losing ground as <a href="http://martinfowler.com/bliki/RubyMicrosoft.html">Martin Fowler</a> suggests? Or is <a href="http://www.businessweek.com/technology/content/dec2005/tc20051213_042973.htm">Java&#8217;s market share dropping</a>? What about Ruby? And what about the Australian market in particular?</p>
<p>Here&#8217;s what I&#8217;ve been able to find.</p>
<p><span style="font-weight: bold;">Job Trends</span><br />
Which technologies have the most demand for people?</p>
<p>From <a href="http://www.indeed.com/jobtrends?q=.net%2C+java%2C+c%23%2C+ruby&#038;l=">Indeed.com</a>, which claims to search &#8220;millions of jobs from thousands of job sites&#8221;, but I suspect may have a USA focus:</p>
<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_TlhwVaDeyBE/RmTGdLuuu0I/AAAAAAAAAW8/Z5uOqrnvNJk/s1600-h/indeed.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/_TlhwVaDeyBE/RmTGdLuuu0I/AAAAAAAAAW8/Z5uOqrnvNJk/s400/indeed.png" alt="" id="BLOGGER_PHOTO_ID_5072397284993317698" border="0" /></a></p>
<p><a href="http://www.vision6.com.au/ch/dx8s7z/236720/f5785zrx3.pdf">&#8220;Best Talent Index May 2007&#8243;</a> from <a href="http://best-international.com.au/">Best People Solutions</a>  gives an Australian perspective:</p>
<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_TlhwVaDeyBE/RmTpGruuu1I/AAAAAAAAAXE/OxDKaQ4KZfY/s1600-h/best.JPG"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp2.blogger.com/_TlhwVaDeyBE/RmTpGruuu1I/AAAAAAAAAXE/OxDKaQ4KZfY/s400/best.JPG" alt="" id="BLOGGER_PHOTO_ID_5072435381353233234" border="0" /></a></p>
<p>Here&#8217;s job counts from the (largest?) primarily Australian job search site <a href="http://www.seek.com.au/">Seek</a> on 5 June 2007, 3pm (today):</p>
<table class="ttable" bordercolordark="#003366" bordercolorlight="#c0c0c0" id="Table2" align="center" border="1">
<tr>
<td><b>Keyword(s)</b></td>
<td><b>Number of positions found</b></td>
</tr>
<tr>
<td>Java</td>
<td>3,414</td>
</tr>
<tr>
<td>&#8220;.NET&#8221; or &#8220;dot net&#8221;</td>
<td>2,744</td>
</tr>
<tr>
<td>&#8220;c#&#8221; or &#8220;c sharp&#8221;</td>
<td>1,722</td>
</tr>
<tr>
<td>ruby</td>
<td>100</td>
</tr>
</table>
<p>As an aside, I remember doing a search on Seek for &#8220;ruby&#8221; about 6 months ago, and getting under 20 jobs mentioning it.</p>
<p><span style="font-weight: bold;">Search Engine Number of Hits</span></p>
<p>Extract from the <a href="http://www.tiobe.com/tiobe_index/index.htm">TIOBE Programming Community Index for June 2007</a>:</p>
<table width="80%" class="ttable" bordercolordark="#003366" bordercolorlight="#c0c0c0" id="Table2" align="center" border="1">
<tbody>
<tr>
<th align="center"> Position<br />
Jun 2007</th>
<th align="center" >Position<br />
Jun 2006</th>
<th align="center" >Delta in Position</th>
<th align="center" >Programming Language</th>
<th align="center" >Ratings<br />
Jun 2007</th>
<th align="center" >Delta<br />
Jun 2006</th>
<th align="center" >Status</th>
</tr>
<tr>
<td align="center">1</td>
<td align="center">1</td>
<td align="center"><img src="http://www.tiobe.com/tiobe_index/images/Same.gif" border="0" /></td>
<td><a href="http://www.tiobe.com/tiobe_index/Java.html">Java</a></td>
<td align="center">20.025%</td>
<td align="center">-1.10%</td>
<td align="left">  A</td>
</tr>
<tr height="25">
<td align="center">2</td>
<td align="center">2</td>
<td align="center"><img src="http://www.tiobe.com/tiobe_index/images/Same.gif" border="0" /></td>
<td><a href="http://www.tiobe.com/tiobe_index/C.html">C</a></td>
<td align="center">15.967%</td>
<td align="center">-2.29%</td>
<td align="left">  A</td>
</tr>
<tr height="25">
<td align="center">3</td>
<td align="center">3</td>
<td align="center"><img src="http://www.tiobe.com/tiobe_index/images/Same.gif" border="0" /></td>
<td><a href="http://www.tiobe.com/tiobe_index/C__.html">C++</a></td>
<td align="center">11.118%</td>
<td align="center">+0.45%</td>
<td align="left">  A</td>
</tr>
<tr height="25">
<td align="center">4</td>
<td align="center">4</td>
<td align="center"><img src="http://www.tiobe.com/tiobe_index/images/Same.gif" border="0" /></td>
<td><a href="http://www.tiobe.com/tiobe_index/%28Visual%29_Basic.html">(Visual) Basic</a></td>
<td align="center">9.332%</td>
<td align="center">-0.85%</td>
<td align="left">  A</td>
</tr>
<tr height="25">
<td align="center">5</td>
<td align="center">5</td>
<td align="center"><img src="http://www.tiobe.com/tiobe_index/images/Same.gif" border="0" /></td>
<td><a href="http://www.tiobe.com/tiobe_index/PHP.html">PHP</a></td>
<td align="center">8.871%</td>
<td align="center">-0.72%</td>
<td align="left">  A</td>
</tr>
<tr height="25">
<td align="center">6</td>
<td align="center">6</td>
<td align="center"><img src="http://www.tiobe.com/tiobe_index/images/Same.gif" border="0" /></td>
<td><a href="http://www.tiobe.com/tiobe_index/Perl.html">Perl</a></td>
<td align="center">6.177%</td>
<td align="center">+0.17%</td>
<td align="left">  A</td>
</tr>
<tr height="25">
<td align="center">7</td>
<td align="center">8</td>
<td align="center"> <img src="http://www.tiobe.com/tiobe_index/images/Up.gif" border="0" /> </td>
<td><a href="http://www.tiobe.com/tiobe_index/C_.html">C#</a></td>
<td align="center">3.483%</td>
<td align="center">+0.25%</td>
<td align="left">  A</td>
</tr>
<tr height="25">
<td align="center">8</td>
<td align="center">7</td>
<td align="center"> <img src="http://www.tiobe.com/tiobe_index/images/Down.gif" border="0" /> </td>
<td><a href="http://www.tiobe.com/tiobe_index/Python.html">Python</a></td>
<td align="center">3.161%</td>
<td align="center">-0.30%</td>
<td align="left">  A</td>
</tr>
<tr height="25">
<td align="center">9</td>
<td align="center">10</td>
<td align="center"> <img src="http://www.tiobe.com/tiobe_index/images/Up.gif" border="0" /> </td>
<td><a href="http://www.tiobe.com/tiobe_index/JavaScript.html">JavaScript</a></td>
<td align="center">2.616%</td>
<td align="center">+1.16%</td>
<td align="left">  A</td>
</tr>
<tr height="25">
<td align="center">10</td>
<td align="center">19</td>
<td align="center"> <img src="http://www.tiobe.com/tiobe_index/images/Up.gif" border="0" /><img src="http://www.tiobe.com/tiobe_index/images/Up.gif" border="0" /><img src="http://www.tiobe.com/tiobe_index/images/Up.gif" border="0" /><img src="http://www.tiobe.com/tiobe_index/images/Up.gif" border="0" /><img src="http://www.tiobe.com/tiobe_index/images/Up.gif" border="0" /><img src="http://www.tiobe.com/tiobe_index/images/Up.gif" border="0" /><img src="http://www.tiobe.com/tiobe_index/images/Up.gif" border="0" /><img src="http://www.tiobe.com/tiobe_index/images/Up.gif" border="0" /><img src="http://www.tiobe.com/tiobe_index/images/Up.gif" border="0" /> </td>
<td><a href="http://www.tiobe.com/tiobe_index/Ruby.html">Ruby</a></td>
<td align="center">2.132%</td>
<td align="center">+1.65%</td>
<td align="left">  A</td>
</tr>
</tbody>
</table>
<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_TlhwVaDeyBE/RmTxsLuuu2I/AAAAAAAAAXM/Klu2QZtQmEw/s1600-h/tpci_trends.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/_TlhwVaDeyBE/RmTxsLuuu2I/AAAAAAAAAXM/Klu2QZtQmEw/s400/tpci_trends.png" alt="" id="BLOGGER_PHOTO_ID_5072444821691349858" border="0" /></a><br />
I think this gives a good idea of web buzz, but suggest that most non-IT companies do not publish information about their projects and chosen technologies and languages on the web.</p>
<p><span style="font-weight: bold;">Conclusion</span><br />
The data collected suggests that:</p>
<ul>
<li>Both .NET and Java are major players in the job market with thousands of positions advertised, implying wide industry adoption of both.</li>
<li>Neither .NET nor Java seem to be undergoing any significant decline in jobs.
</li>
<li>Java has much more information about it on the internet, although .NET is slowing gaining ground and Java slowly losing it.
</li>
<li>Ruby is comparatively tiny but growing rapidly in terms of jobs and information on the internet.
</li>
</ul>
<p><span style="font-weight:bold;">Thanks</span><br />
Thanks to <a href="http://jchyip.blogspot.com/">Jason Yip</a> and <a href="http://binkysilhouette.blogspot.com/">Suzi Edwards</a> for their help finding/sourcing information.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2007/06/05/is-net-or-java-dying/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using floating point variables to represent money =&#62; not a good idea!</title>
		<link>http://jamescrisp.org/2007/02/25/using-floating-point-variables-to-represent-money-not-a-good-idea/</link>
		<comments>http://jamescrisp.org/2007/02/25/using-floating-point-variables-to-represent-money-not-a-good-idea/#comments</comments>
		<pubDate>Sun, 25 Feb 2007 10:59:00 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[Java]]></category>

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

		<category><![CDATA[Ruby / Rails]]></category>

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

		<guid isPermaLink="false">http://jamescrisp.org/wordpress/?p=42</guid>
		<description><![CDATA[I was reading through some code the other day and was surprised to find that it was using doubles to represent  dollar amounts. Reason for the alarm bells is that doubles and floats cannot accurately represent many decimal fractions (eg, 0.1), since doubles and floats internally work with powers of 2 rather than powers [...]]]></description>
			<content:encoded><![CDATA[<p>I was reading through some code the other day and was surprised to find that it was using doubles to represent  dollar amounts. Reason for the alarm bells is that doubles and floats cannot accurately represent many decimal fractions (<span class="blsp-spelling-error" id="SPELLING_ERROR_0">eg</span>, 0.1), since doubles and floats internally work with powers of 2 rather than powers of 10. These inaccuracies are likely to lead to significant errors, especially when performing arithmetic (<span class="blsp-spelling-error" id="SPELLING_ERROR_1">eg</span>, adding up a table of dollar amounts). See this <a href="http://www2.hursley.ibm.com/decimal/decifaq1.html#inexact">IBM article</a> for a more <span class="blsp-spelling-corrected" id="SPELLING_ERROR_2">in depth</span> explanation and examples. The solution is to use types that work with powers of ten internally. In C#, you can use &#8216;decimal&#8217; and in Java or Ruby, &#8216;<span class="blsp-spelling-error" id="SPELLING_ERROR_3">BigDecimal</span>&#8216;, to avoid these problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2007/02/25/using-floating-point-variables-to-represent-money-not-a-good-idea/feed/</wfw:commentRss>
		</item>
		<item>
		<title>AntiPattern: BusinessObjects in the driving seat</title>
		<link>http://jamescrisp.org/2007/01/11/antipattern-businessobjects-in-the-driving-seat/</link>
		<comments>http://jamescrisp.org/2007/01/11/antipattern-businessobjects-in-the-driving-seat/#comments</comments>
		<pubDate>Fri, 12 Jan 2007 00:51:00 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[C#]]></category>

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

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

		<guid isPermaLink="false">http://jamescrisp.org/wordpress/?p=37</guid>
		<description><![CDATA[When you have a rich domain model with a business object centric design, and a Windows forms GUI, it can be very tempting to start putting significant process logic in the business objects. After continuing along this path a little further, you may realise that the process needs some sort of user input, and you [...]]]></description>
			<content:encoded><![CDATA[<p>When you have a rich domain model with a business object centric design, and a Windows forms GUI, it can be very tempting to start putting significant process logic in the business objects. After continuing along this path a little further, you may realise that the process needs some sort of user input, and you use events or some sort of notifier pattern to gain user input required by the process, while still maintaining layering in terms of referencing. Then additionally you may need to access some sort of external service.</p>
<p>Here is an example:</p>
<pre>class Order : BusinessObject
{
  public void SendOrder(INotifier notifier)
  {
    if (ReadyForDelivery ||
        notifier.Confirm("Are you sure you want to send order lines? They are not ready for delivery."))
    {
      OrderLine[] orders = GetLinesToSend();
      foreach(OrderLine line in Lines)
      {
        SendLine(line); // send line using a web service?
      }

      Notify("Lines sent successfully.");
    }
  }
}

interface INotifier
{
  void Notify(string msg);
  bool Confirm(string msg);
  OrderLine[] GetLinesToSend();
}</pre>
<p>I would like to suggest that this is an anti-pattern and a trap. Although there is no direct reference from the Business Layer to the GUI layer (INotifier is implemented in GUI and passed down), the Business Layer now requires the ability to stay instantiated, pause while waiting for responses from the notifier, and then continue execution. This will work for rich client applications, but not in a stateless web environment. The ideal of being able to swap in/out the GUI layers on top of the Business layer is now compromised.</p>
<p>Instead, it would be possible to drive form the GUI layer, and call a service to send the Order Lines. In pseudo code below:</p>
<pre>void SendMenu_Click(...)
{
  if (Order.ReadyForDelivery ||
      MessageBox.Show(...) == DialogResult.Yes)
  {
    using (ChooseLineForm chooseLineForm = new ChooseLineForm(Order))
    {
      chooseLineForm.ShowDialog()
    }
    SendingSevice.SendLines(chooseLineForm.selectedLines);
    ...
  }
}</pre>
<p>If the logic in the GUI layer became much more complex, it may be a good idea to pull it out into its own class (eg, LineSender). This class would be a type of GUI level controller, responsible for orchestrating the send process.</p>
<p>Using this approach, there are a number of benefits:</p>
<ul>
<li>BusinessObjects have no reliance on GUI implementation, so can be used for Rich Client and Web Client indiscriminately.</li>
<li>Web developers are free to implement the user input process in stateless way more appropriate to their platform.</li>
<li>Functionality for sending Order lines (some sort of integration with a web service?) is pulled out into a service class which can be reused elsewhere (potentially sending other types of objects?) and unclutters the Order business object and removes its dependency  on  an external service.</li>
<li>Code is simpler and easier to follow.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jamescrisp.org/2007/01/11/antipattern-businessobjects-in-the-driving-seat/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
