<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>mhinze.com</title>
	
	<link>http://mhinze.com</link>
	<description>Matt Hinze's web log</description>
	<lastBuildDate>Tue, 17 Nov 2009 13:04:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/mhinzecom" type="application/rss+xml" /><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fmhinzecom" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fmhinzecom" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Fmhinzecom" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.bloglines.com/sub/http://feeds.feedburner.com/mhinzecom" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fmhinzecom" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fmhinzecom" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fmhinzecom" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Breaking up with the ternary operator</title>
		<link>http://mhinze.com/breaking-up-with-the-ternary-operator/</link>
		<comments>http://mhinze.com/breaking-up-with-the-ternary-operator/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 11:17:58 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://mhinze.com/breaking-up-with-the-ternary-operator/</guid>
		<description><![CDATA[I love the ternary operator.&#160; It&#8217;s so terse and clever.&#160; It&#8217;s been my bread and butter for years.&#160; It does things no other operator can do, and on three operands!&#160; It&#8217;s really a shining example of programming language designer genius.&#160; 
But lately we&#8217;ve been having problems.&#160; Things between us just aren&#8217;t working out.
I generally catch [...]]]></description>
			<content:encoded><![CDATA[<p>I love the ternary operator.&#160; It&#8217;s so terse and clever.&#160; It&#8217;s been my bread and butter for years.&#160; It does things no other operator can do, and on three operands!&#160; It&#8217;s really a shining example of programming language designer <em>genius</em>.&#160; </p>
<p>But lately we&#8217;ve been having problems.&#160; Things between us just aren&#8217;t working out.</p>
<p>I generally catch it sneaking around, hiding complexity in a quick line of seemingly meaningless symbols.&#160; I won&#8217;t stand for it any longer.&#160; </p>
<p>I hardly ever actually type it out, anyway.&#160; I always use Resharper to craft it from an existing if statement. </p>
<p>It&#8217;s not that I don&#8217;t understand the ternary operator.&#160; I do.&#160; But as it increases the time-to-comprehension while reading and maintaining source code by even one tick, its unholy presence can accumulate an untenable viscosity in my workflow.</p>
<p>Reading code I&#8217;ve previously written, I find myself using Resharper to decode those same ternary operators back into if statements.</p>
<p>Source code should be easy to write and easy to read.&#160; There are very few contexts in which I&#8217;ll tolerate greater terseness over comprehensibility.</p>
<p>Ternary operator, pack your bags.&#160; It&#8217;s not you it&#8217;s me.</p>
]]></content:encoded>
			<wfw:commentRss>http://mhinze.com/breaking-up-with-the-ternary-operator/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Aggregated specifications</title>
		<link>http://mhinze.com/aggregated-specifications/</link>
		<comments>http://mhinze.com/aggregated-specifications/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 11:07:53 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Domain-Driven Design]]></category>

		<guid isPermaLink="false">http://mhinze.com/aggregated-specifications/</guid>
		<description><![CDATA[An example from my inversion of control talk involves a message formatter.&#160; It applies formatting rules to a string. 
public interface IMessageFomatter
{
    string Format(string message);
}

Instead of doing all the work in the implementation of this interface, the message formatter will aggregate several distinct rules.&#160; An inversion of control tool is configured to [...]]]></description>
			<content:encoded><![CDATA[<p>An example from my inversion of control talk involves a message formatter.&#160; It applies formatting rules to a string. </p>
<pre class="code"><span style="color: blue">public interface </span><span style="color: #2b91af">IMessageFomatter
</span>{
    <span style="color: blue">string </span>Format(<span style="color: blue">string </span>message);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Instead of doing all the work in the implementation of this interface, the message formatter will aggregate several distinct rules.&#160; An inversion of control tool is configured to compose these rules and provide them to the formatter.</p>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">MessageFomatter </span>: <span style="color: #2b91af">IMessageFomatter
</span>{
    <span style="color: blue">private readonly </span><span style="color: #2b91af">IFormatRule</span>[] _rules;

    <span style="color: blue">public </span>MessageFomatter(<span style="color: #2b91af">IFormatRule</span>[] rules)
    {
        _rules = rules;
    }

    <span style="color: blue">public string </span>Format(<span style="color: blue">string </span>message)
    {
        <span style="color: blue">foreach </span>(<span style="color: blue">var </span>action <span style="color: blue">in </span>_rules)
        {
            message = action.ApplyRule(message);
        }
        <span style="color: blue">return </span>message;
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>In this way each rule can be small, testable, and have only one job.&#160; I can add functionality to the formatting process without changing the formatter or any existing rule.&#160; </p>
<pre class="code"><span style="color: blue">public interface </span><span style="color: #2b91af">IFormatRule
</span>{
    <span style="color: blue">string </span>ApplyRule(<span style="color: blue">string </span>text);
}

<span style="color: blue">public class </span><span style="color: #2b91af">DisclaimerRule </span>: <span style="color: #2b91af">IFormatRule
</span>{
    <span style="color: blue">public string </span>ApplyRule(<span style="color: blue">string </span>text)
    {
        <span style="color: blue">return </span>text + <span style="color: #a31515">&quot;\nDisclaimer: This message will self-destruct&quot;</span>;
    }
}

<span style="color: blue">public class </span><span style="color: #2b91af">UppercaseRule </span>: <span style="color: #2b91af">IFormatRule
</span>{
    <span style="color: blue">public string </span>ApplyRule(<span style="color: blue">string </span>text)
    {
        <span style="color: blue">return </span>text.ToUpper();
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>This technique is extremely powerful and <a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/03/17/a-better-model-binder.aspx">we use it all over the place in our projects</a>.</p>
<p>Recently we were building a search screen.&#160; It has several text input boxes and select lists and radio button groups, you know, the standard enterprisey UI mess.&#160; Anyway, that&#8217;s what it was and it&#8217;s a common feature in the apps I work on. I&#8217;ve seen the scenario over and over. But armed with the above technique and LINQ to NHibernate, we were able to craft a much more elegant solution than we had previously created.</p>
<p>First we have a type that represents the search query.&#160; It could be implemented by the class that represents the user interface form or be built by the user interface layer.&#160; It&#8217;s sent to a service that will perform the query.</p>
<pre class="code"><span style="color: blue">public interface </span><span style="color: #2b91af">IProductSearchQuery
</span>{
    <span style="color: blue">decimal</span>? Price { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">int</span>? PriceRange { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">string </span>Name { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: #2b91af">ProductCategory </span>Category { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: green">// ...
</span>}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<pre class="code"><span style="color: blue">public interface </span><span style="color: #2b91af">IProductRepository
</span>{
    <span style="color: #2b91af">Product</span>[] Search(<span style="color: #2b91af">IProductSearchQuery </span>query);
    <span style="color: green">// ...
</span>}</pre>
<p>What we don&#8217;t want is a huge method that checks to see if a search criteria exists and then conditionally appends predicates to a database query.&#160; That&#8217;s the old school way, and it&#8217;s a beast to test and to change.&#160; Adding a user interface element, like a new text input field, would require us to change that big method by introducing repetitive and dangerous new code.</p>
<p>What we do want are <a href="http://ubik.com.au/article/named/implementing_the_specification_pattern_with_linq">small, isolated specifications</a> that we can aggregate like the message formatter.</p>
<pre class="code"><span style="color: blue">public interface </span><span style="color: #2b91af">IProductSearchFilter
</span>{
    <span style="color: blue">bool </span>ShouldApply(<span style="color: #2b91af">IProductSearchQuery </span>query);
    <span style="color: #2b91af">IQueryable</span>&lt;<span style="color: #2b91af">Product</span>&gt; Filter(<span style="color: #2b91af">IQueryable</span>&lt;<span style="color: #2b91af">Product</span>&gt; candidates, <span style="color: #2b91af">IProductSearchQuery </span>query);
}</pre>
<p>An example filter:</p>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">PriceRangeFilter </span>: <span style="color: #2b91af">IProductSearchFilter
</span>{
    <span style="color: blue">public bool </span>ShouldApply(<span style="color: #2b91af">IProductSearchQuery </span>query)
    {
        <span style="color: blue">return </span>query.Price.HasValue &amp;&amp; query.PriceRange.HasValue;
    }

    <span style="color: blue">public </span><span style="color: #2b91af">IQueryable</span>&lt;<span style="color: #2b91af">Product</span>&gt; Filter(<span style="color: #2b91af">IQueryable</span>&lt;<span style="color: #2b91af">Product</span>&gt; candidates, <span style="color: #2b91af">IProductSearchQuery </span>query)
    {
        <span style="color: blue">return from </span>product <span style="color: blue">in </span>candidates
               <span style="color: blue">where </span>product.Price &lt;= (query.Price + query.PriceRange)
               &amp;&amp; product.Price &gt;= (query.Price - query.PriceRange)
               <span style="color: blue">select </span>product;
    }
}</pre>
<p>You can test drive this thing.&#160; It&#8217;s small and distinct.&#160; And using LINQ to NHibernate you can combine several of them in a way that produces one select.</p>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">ProductRepository </span>: <span style="color: #2b91af">IProductRepository
</span>{
    <span style="color: blue">private readonly </span><span style="color: #2b91af">ISession </span>_session;
    <span style="color: blue">private readonly </span><span style="color: #2b91af">IProductSearchFilter</span>[] _filters;

    <span style="color: blue">public </span>ProductRepository(<span style="color: #2b91af">ISession </span>session, <span style="color: #2b91af">IProductSearchFilter</span>[] filters)
    {
        _session = session;
        _filters = filters;
    }

    <span style="color: blue">public </span><span style="color: #2b91af">Product</span>[] Search(<span style="color: #2b91af">IProductSearchQuery </span>query)
    {
        <span style="color: blue">var </span>products = _session.Linq&lt;<span style="color: #2b91af">Product</span>&gt;();
        <span style="color: blue">return </span>_filters
            .Where(x =&gt; x.ShouldApply(query))
            .Aggregate(products, (candidates, filter) =&gt;
                filter.Filter(candidates, query)).ToArray();
    }

    <span style="color: green">// ...
</span>}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>One tricky spot for a lot of people is that Aggregate call.&#160; It does the exact same thing as the foreach in the message formatter: passes the seed (products, in this case) through the filters aggregating the result.&#160; The lambda parameter variable candidates is the result of the previous filter (or the seed for the first filter).&#160; In other ecosystems besides .NET, Aggregate is called reduce.&#160; You can see why &#8211; each filter reduces the candidates according to its specification.</p>
<p>When you think about it, an <a href="http://www.google.com/webhp#hl=en&amp;q=mapreduce+architecture">entire architecture could be a reduce</a>. That would be <em>really</em> interesting.</p>
]]></content:encoded>
			<wfw:commentRss>http://mhinze.com/aggregated-specifications/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Microsoft MVP</title>
		<link>http://mhinze.com/microsoft-mvp/</link>
		<comments>http://mhinze.com/microsoft-mvp/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 20:15:53 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Community]]></category>

		<guid isPermaLink="false">http://mhinze.com/microsoft-mvp/</guid>
		<description><![CDATA[I received word today that I&#8217;m a Microsoft MVP for C#.&#160; Cool.
This next bit is going to read like some phony sales pitch or something but it&#8217;s legitimate:
I got the award because I work at a great company that nurtures community involvement, encourages open source contribution and gives me the opportunity to develop and deliver [...]]]></description>
			<content:encoded><![CDATA[<p>I received word today that I&#8217;m a Microsoft MVP for C#.&#160; Cool.</p>
<p>This next bit is going to read like some phony sales pitch or something but it&#8217;s legitimate:</p>
<p>I got the award because I work at a <a href="http://headspringsystems.com">great company</a> that nurtures community involvement, encourages open source contribution and gives me the opportunity to develop and deliver high quality courseware for programmers.&#160; I also work every day in the IDE and whiteboard trenches with an incredibly talented team of developers who foster a real culture of continuous improvement.</p>
]]></content:encoded>
			<wfw:commentRss>http://mhinze.com/microsoft-mvp/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>AutoMapper in NerdDinner</title>
		<link>http://mhinze.com/automapper-in-nerddinner/</link>
		<comments>http://mhinze.com/automapper-in-nerddinner/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 11:00:00 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[automapper]]></category>

		<guid isPermaLink="false">http://mhinze.com/automapper-in-nerddinner/</guid>
		<description><![CDATA[
Speaking of NerdDinner, Scott asked me to use it to create an AutoMapper example.  
AutoMapper, the brainchild of Jimmy Bogard, is an object-to-object mapper.&#160; What that means is up to you &#8211; but we&#8217;ll use it here to map from the domain model to a view model.&#160; The view model is an object heirarchy [...]]]></description>
			<content:encoded><![CDATA[</p>
<p><a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/07/03/how-not-to-do-dependency-injection-in-nerddinner.aspx">Speaking</a> of <a href="http://nerddinner.codeplex.com/">NerdDinner</a>, <a href="http://www.hanselman.com/blog/">Scott</a> <a href="http://twitter.com/shanselman/status/2441262483">asked me</a> to use it to create an <a href="http://code.google.com/p/automapperhome/">AutoMapper</a> example. <a href="http://mhinze.com/wp-content/uploads/2009/07/logo.png"><img title="logo" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 0px 15px 20px; border-right-width: 0px" height="90" alt="logo" src="http://mhinze.com/wp-content/uploads/2009/07/logo_thumb.png" width="244" align="right" border="0" /></a> </p>
<p>AutoMapper, the brainchild of <a href="http://www.lostechies.com/blogs/jimmy_bogard/default.aspx">Jimmy Bogard</a>, is an object-to-object mapper.&#160; What that means is up to you &#8211; but we&#8217;ll use it here to map from the domain model to a view model.&#160; The view model is an object heirarchy that represents the screen.&#160; It&#8217;s as dumb as possible, just like the view.</p>
<p>We get a lot of nice things out of it and it helps us go faster.&#160; You can read more about it AutoMapper from <a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/tags/AutoMapper/default.aspx">Jimmy</a> or at the website on <a href="http://www.codeplex.com/AutoMapper">Codeplex</a>.</p>
<p>For starters, NerdDinner isn&#8217;t the best scenario in which to apply AutoMapper.&#160; NerdDinner is very small so there&#8217;s not much reuse to harvest. For example, if you format dates the same way a million times you can use AutoMapper to only write that formatting code once.&#160; In a small application you may format dates two ways and only use the resulting text in two views.&#160; It doesn&#8217;t make a lot of sense to extract a class just for that &#8211; it will seem like a lot of overhead.&#160; </p>
<p>Also NerdDinner doesn&#8217;t have a rich domain model &#8211; there&#8217;s just not that much to do.&#160; So the AutoMapper feature of <a href="http://automapper.codeplex.com/Wiki/View.aspx?title=Flattening">flattening complex hierarchies</a> can&#8217;t be appreciated. </p>
<p>I posted <a href="http://mhinze.com/static-content/nerddinner-23425-automapper.zip"><strong>the result of this quick and dirty spike</strong></a> as a sample project &#8211; hopefully this will help you get started looking at it.</p>
<p>First, I copypasted a class to bootstrap AutoMapper:</p>
<pre class="code"><span style="color: blue">namespace </span>NerdDinner.Helpers.AutoMapper
{
    <span style="color: blue">public class </span><span style="color: #2b91af">AutoMapperConfiguration
    </span>{
        <span style="color: blue">public static void </span>Configure()
        {
            <span style="color: #2b91af">Mapper</span>.Initialize(x =&gt; x.AddProfile&lt;<span style="color: #2b91af">ViewModelProfile</span>&gt;());
        }
    }
}</pre>
<p>.. which will be called when the application starts:</p>
<pre class="code"><span style="color: blue">void </span>Application_Start()
{
    <span style="color: #2b91af">AutoMapperConfiguration</span>.Configure();

    RegisterRoutes(<span style="color: #2b91af">RouteTable</span>.Routes);

    <span style="color: #2b91af">ViewEngines</span>.Engines.Clear();
    <span style="color: #2b91af">ViewEngines</span>.Engines.Add(<span style="color: blue">new </span><span style="color: #2b91af">MobileCapableWebFormViewEngine</span>());
}</pre>
<p>I copypasted another class that will check the mapping configuration for errors, providing fast feedback should I make a mistake. </p>
<pre class="code">[<span style="color: #2b91af">TestClass</span>]
<span style="color: blue">public class </span><span style="color: #2b91af">AutoMapperConfigurationTester
</span>{
    [<span style="color: #2b91af">TestMethod</span>]
    <span style="color: blue">public void </span>Should_map_dtos()
    {
        <span style="color: #2b91af">AutoMapperConfiguration</span>.Configure();
        <span style="color: #2b91af">Mapper</span>.AssertConfigurationIsValid();
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a>Now I&#8217;m ready to begin creating the view model and configuring AutoMapper. </p>
<p>To design a view model, start with the screen.&#160; What&#8217;s displayed will be represented in the model.&#160; Again: the view model is an object hierarchy that represents the user interface.&#160; I picked the Dinner Details screen, by the way. </p>
<p>The current model being used by the view was the Dinner entity itself.&#160; There was a lot of formatting in the view and a lot of duplication.</p>
<p>Almost every property was surrounded by code that would HtmlEncode it (it will be nice to have AutoMapper do this for us):</p>
<pre class="code"><span style="background: #ffee62">&lt;%</span><span style="color: blue">= </span>Html.Encode(Model.Title) <span style="background: #ffee62">%&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a>And there is a lot of formatting to do:</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">abbr </span><span style="color: red">class</span><span style="color: blue">=&quot;dtstart&quot; </span><span style="color: red">title</span><span style="color: blue">=&quot;</span><span style="background: #ffee62">&lt;%</span>= Model.EventDate.ToString(&quot;s&quot;) <span style="background: #ffee62">%&gt;</span><span style="color: blue">&quot;&gt;
    </span><span style="background: #ffee62">&lt;%</span><span style="color: blue">= </span>Model.EventDate.ToString(<span style="color: #a31515">&quot;MMM dd, yyyy&quot;</span>) <span style="background: #ffee62">%&gt;</span>
    <span style="color: blue">&lt;</span><span style="color: #a31515">strong</span><span style="color: blue">&gt;</span>@<span style="color: blue">&lt;/</span><span style="color: #a31515">strong</span><span style="color: blue">&gt;
    </span><span style="background: #ffee62">&lt;%</span><span style="color: blue">= </span>Model.EventDate.ToShortTimeString() <span style="background: #ffee62">%&gt;
</span><span style="color: blue">&lt;/</span><span style="color: #a31515">abbr</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a>Imagine a project with 300 screens and a team of analysts and you can imagine that specifying this formatting over and over again in requirements documents and planning would become tedious.&#160; Not to mention coding it.&#160; It&#8217;d be easier to just say: &#8220;Format this date in the standard way.&#8221; You can also imagine the security implications of forgetting to encode even one value.</p>
<p>In converting these screens to use a view model instead of the domain model I didn&#8217;t want to change existing functionality.&#160; So I took this:</p>
<pre class="code"><span style="background: #ffee62">&lt;%</span><span style="color: blue">@ </span><span style="color: #a31515">Page </span><span style="color: red">Language</span><span style="color: blue">=&quot;C#&quot; </span><span style="color: red">Inherits</span><span style="color: blue">=&quot;System.Web.Mvc.ViewPage&lt;NerdDinner.Models.Dinner&gt;&quot;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a>and changed it to this:</p>
<pre class="code"><span style="background: #ffee62">&lt;%</span><span style="color: blue">@ </span><span style="color: #a31515">Page </span><span style="color: red">Language</span><span style="color: blue">=&quot;C#&quot; </span><span style="color: red">Inherits</span><span style="color: blue">=&quot;System.Web.Mvc.ViewPage&lt;DinnerDetailsViewModel&gt;&quot;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a>See what I did there?&#160; I just changed the type of the Model property to a new DinnerDetailsViewModel type.</p>
<p>The view will receive a view model mapped from the domain model when I apply a special action filter to the controller action:</p>
<pre class="code">[<span style="color: #2b91af">AutoMap</span>(<span style="color: blue">typeof</span>(<span style="color: #2b91af">Dinner</span>), <span style="color: blue">typeof</span>(<span style="color: #2b91af">DinnerDetailsViewModel</span>))]</pre>
<p>The code&#8217;s in the sample, straight from <a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/06/29/how-we-do-mvc-view-models.aspx">Jimmy&#8217;s post</a>.</p>
<p>I started out with DinnerDetailsViewModel being an empty class definition and used Resharper to generate each property as I encountered it.&#160; I removed the formatting and the ubiquitous encoding from the parameters, turning this:</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">div </span><span style="color: red">id</span><span style="color: blue">=&quot;dinnerDiv&quot; </span><span style="color: red">class</span><span style="color: blue">=&quot;vevent&quot;&gt;

    &lt;</span><span style="color: #a31515">h2 </span><span style="color: red">class</span><span style="color: blue">=&quot;summary&quot;&gt;</span><span style="background: #ffee62">&lt;%</span><span style="color: blue">= </span>Html.Encode(Model.Title) <span style="background: #ffee62">%&gt;</span><span style="color: blue">&lt;/</span><span style="color: #a31515">h2</span><span style="color: blue">&gt;

    &lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">a </span><span style="color: red">href</span><span style="color: blue">=&quot;http://feeds.technorati.com/events/</span><span style="background: #ffee62">&lt;%</span>= Url.AbsoluteAction(&quot;Details&quot;, new { id = Model.DinnerID }) <span style="background: #ffee62">%&gt;</span><span style="color: blue">&quot;&gt;
            </span>Add event to your calendar (iCal)
        <span style="color: blue">&lt;/</span><span style="color: #a31515">a</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;

    &lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">strong</span><span style="color: blue">&gt;</span>When:<span style="color: blue">&lt;/</span><span style="color: #a31515">strong</span><span style="color: blue">&gt;
&lt;</span><span style="color: #a31515">abbr </span><span style="color: red">class</span><span style="color: blue">=&quot;dtstart&quot; </span><span style="color: red">title</span><span style="color: blue">=&quot;</span><span style="background: #ffee62">&lt;%</span>= Model.EventDate.ToString(&quot;s&quot;) <span style="background: #ffee62">%&gt;</span><span style="color: blue">&quot;&gt;
</span><span style="background: #ffee62">&lt;%</span><span style="color: blue">= </span>Model.EventDate.ToString(<span style="color: #a31515">&quot;MMM dd, yyyy&quot;</span>) <span style="background: #ffee62">%&gt;</span>
<span style="color: blue">&lt;</span><span style="color: #a31515">strong</span><span style="color: blue">&gt;</span>@<span style="color: blue">&lt;/</span><span style="color: #a31515">strong</span><span style="color: blue">&gt;
</span><span style="background: #ffee62">&lt;%</span><span style="color: blue">= </span>Model.EventDate.ToShortTimeString() <span style="background: #ffee62">%&gt;
</span><span style="color: blue">&lt;/</span><span style="color: #a31515">abbr</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a>into this:</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">h2 </span><span style="color: red">class</span><span style="color: blue">=&quot;summary&quot;&gt;</span><span style="background: #ffee62">&lt;%</span><span style="color: blue">= </span>Model.Title <span style="background: #ffee62">%&gt;</span><span style="color: blue">&lt;/</span><span style="color: #a31515">h2</span><span style="color: blue">&gt;

&lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">a </span><span style="color: red">href</span><span style="color: blue">=&quot;http://feeds.technorati.com/events/</span><span style="background: #ffee62">&lt;%</span>= Url.AbsoluteAction(&quot;Details&quot;, new { id = Model.DinnerID }) <span style="background: #ffee62">%&gt;</span><span style="color: blue">&quot;&gt;
        </span>Add event to your calendar (iCal)
    <span style="color: blue">&lt;/</span><span style="color: #a31515">a</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;

&lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">strong</span><span style="color: blue">&gt;</span>When:<span style="color: blue">&lt;/</span><span style="color: #a31515">strong</span><span style="color: blue">&gt;
    </span><span style="background: #ffee62">&lt;%</span><span style="color: blue">= </span>Model.EventDate <span style="background: #ffee62">%&gt;
</span><span style="color: blue">&lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p><a href="http://11011.net/software/vspaste"></a>I had to write a formatter to replace the custom formatting performed by the view. </p>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">AttendeeNameFormatter </span>: <span style="color: #2b91af">BaseFormatter</span>&lt;<span style="color: blue">string</span>&gt;
{
    <span style="color: blue">protected override string </span>FormatValueCore(<span style="color: blue">string </span>value)
    {
        <span style="color: blue">return </span>value.Replace(<span style="color: #a31515">&quot;@&quot;</span>, <span style="color: #a31515">&quot; at &quot;</span>);
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p><a href="http://11011.net/software/vspaste"></a>See how testable that is; small and reusable?</p>
<p><a href="http://11011.net/software/vspaste"></a>I also moved some methods that were previously being called from the view directly into the domain model which AutoMapper will evaluate at runtime. </p>
<p>Before:</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">p </span><span style="color: red">id</span><span style="color: blue">=&quot;whoscoming&quot;&gt;
    &lt;</span><span style="color: #a31515">strong</span><span style="color: blue">&gt;</span>Who's Coming:<span style="color: blue">&lt;/</span><span style="color: #a31515">strong</span><span style="color: blue">&gt;
    </span><span style="background: #ffee62">&lt;%</span><span style="color: blue">if </span>(Model.RSVPs.Count == 0){<span style="background: #ffee62">%&gt;
</span>          No one has registered.
    <span style="background: #ffee62">&lt;%</span> } <span style="background: #ffee62">%&gt;
</span><span style="color: blue">&lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a>After:</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">p </span><span style="color: red">id</span><span style="color: blue">=&quot;whoscoming&quot;&gt;
    &lt;</span><span style="color: #a31515">strong</span><span style="color: blue">&gt;</span>Who's Coming:<span style="color: blue">&lt;/</span><span style="color: #a31515">strong</span><span style="color: blue">&gt;
    </span><span style="background: #ffee62">&lt;%</span><span style="color: blue">if </span>(Model.IsNobodyRegistered){<span style="background: #ffee62">%&gt;
</span>          No one has registered.
    <span style="background: #ffee62">&lt;%</span> } <span style="background: #ffee62">%&gt;
</span><span style="color: blue">&lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;</span></pre>
<p>The view model for this screen ends up looking like this:</p>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">DinnerDetailsViewModel
</span>{
    <span style="color: blue">public string </span>Address { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">public string </span>Title { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">public string </span>DinnerID { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">public string </span>EventDate { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">public string </span>Country { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">public string </span>Latitude { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">public string </span>Longitude { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">public string </span>Description { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">public string </span>HostedBy { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">public string </span>ContactPhone { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">public bool </span>IsAnyoneRegistered { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">public bool </span>IsNobodyRegistered { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">public bool </span>IsCurrentUserRegistered { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    <span style="color: blue">public bool </span>IsCurrentUserHosting { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }

    <span style="color: blue">public </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">RsvpViewModel</span>&gt; RSVPs { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }

    <span style="color: blue">public class </span><span style="color: #2b91af">RsvpViewModel
    </span>{
        <span style="color: blue">public string </span>AttendeeName { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
    }
}</pre>
<p>The really key part is the AutoMapper configuration profile.&#160; You can group configurations with profiles.&#160; Maybe in one profile you format dates in one way, in another profile you format dates in another way.&#160; I&#8217;m just using one profile here.</p>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">ViewModelProfile </span>: <span style="color: #2b91af">Profile
</span>{
    <span style="color: blue">protected override string </span>ProfileName
    {
        <span style="color: blue">get </span>{ <span style="color: blue">return </span><span style="color: #a31515">&quot;ViewModel&quot;</span>; }
    }

    <span style="color: blue">protected override void </span>Configure()
    {
        AddFormatter&lt;<span style="color: #2b91af">HtmlEncoderFormatter</span>&gt;();
        ForSourceType&lt;<span style="color: #2b91af">DateTime</span>&gt;().AddFormatter&lt;<span style="color: #2b91af">StandardDateFormatter</span>&gt;();

        CreateMap&lt;<span style="color: #2b91af">Dinner</span>, <span style="color: #2b91af">DinnerDetailsViewModel</span>&gt;()
            .ForMember(x =&gt; x.IsCurrentUserRegistered, o =&gt; o.ResolveUsing&lt;<span style="color: #2b91af">CurrentUserRegisteredResolver</span>&gt;())
            .ForMember(x =&gt; x.IsCurrentUserHosting, o =&gt; o.ResolveUsing&lt;<span style="color: #2b91af">CurrentUserHostingResolver</span>&gt;())
            .ForMember(x =&gt; x.EventDate, o =&gt; o.SkipFormatter&lt;<span style="color: #2b91af">HtmlEncoderFormatter</span>&gt;());

        CreateMap&lt;<span style="color: #2b91af">RSVP</span>, <span style="color: #2b91af">DinnerDetailsViewModel</span>.<span style="color: #2b91af">RsvpViewModel</span>&gt;()
            .ForMember(x =&gt; x.AttendeeName, o =&gt; o.AddFormatter&lt;<span style="color: #2b91af">AttendeeNameFormatter</span>&gt;());
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p><a href="http://11011.net/software/vspaste"></a>Most properties of the view model are mapped conventionally.&#160; The property names match up so AutoMapper knows exactly what do do with them.&#160; AutoMapper will do a lot more for you if you&#8217;d like it to.&#160; This is actually a pretty hefty configuration.&#160; In a different scenario it&#8217;d be likely that almost everything is mapped conventionally.</p>
<p>Note the first AddFormatter call.&#160; That&#8217;s instructing AutoMapper to html encode everything.&#160; I skip it for a property later.&#160; The possibilities here are endless.&#160; One cool thing we do <a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/04/24/how-we-do-mvc.aspx">in another project</a> is wrap each property in a span that&#8217;s given a conventionally named CSS class.&#160; In automated UI tests, we can use that class to find the proper element and ensure that the screen is displaying the right thing.</p>
<p><a href="http://mhinze.com/wp-content/uploads/2009/07/image.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="204" alt="image" src="http://mhinze.com/wp-content/uploads/2009/07/image_thumb.png" width="244" border="0" /></a></p>
<p>Let me know if you have any questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://mhinze.com/automapper-in-nerddinner/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Free ASP.NET MVC event in Austin</title>
		<link>http://mhinze.com/free-aspnet-mvc-event-in-austin/</link>
		<comments>http://mhinze.com/free-aspnet-mvc-event-in-austin/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 11:59:59 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[training]]></category>

		<guid isPermaLink="false">http://mhinze.com/free-aspnet-mvc-event-in-austin/</guid>
		<description><![CDATA[Jeffrey and Eric will be delivering a free afternoon of ASP.NET MVC in Austin on Tuesday, June 16th.&#160; If you haven&#8217;t yet had a run-in with the new framework or if you&#8217;re ready to see what we&#8217;ve learned using ASP.NET MVC in the field, this afternoon will be an excellent opportunity to compress learning and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jeffreypalermo.com">Jeffrey</a> and <a href="http://www.lostechies.com/blogs/hex/">Eric</a> will be delivering a free <a href="http://www.headspringsystems.com/services/agile-training/mvc-training/">afternoon of ASP.NET MVC in Austin on Tuesday, June 16th</a>.&nbsp; If you haven&#8217;t yet had a run-in with the new framework or if you&#8217;re ready to see what we&#8217;ve learned using ASP.NET MVC in the field, this afternoon will be an excellent opportunity to compress learning and maximize your time&#8230;&nbsp; </p>
]]></content:encoded>
			<wfw:commentRss>http://mhinze.com/free-aspnet-mvc-event-in-austin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Nested Closure</title>
		<link>http://mhinze.com/simple-nested-closure/</link>
		<comments>http://mhinze.com/simple-nested-closure/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 02:42:33 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[dsl]]></category>
		<category><![CDATA[fluent interface]]></category>
		<category><![CDATA[patterns]]></category>

		<guid isPermaLink="false">http://mhinze.com/simple-nested-closure/</guid>
		<description><![CDATA[Nested closure is one of those fancy patterns Martin Fowler first coined (as far as I know) and published on his DSL WIP site. His formal definition:
Express statement sub-elements of a function call by putting them into a closure in an argument.

You pass a delegate as a method parameter. The receiving method executes the function [...]]]></description>
			<content:encoded><![CDATA[<p>Nested closure is one of those fancy patterns <a href="http://martinfowler.com/dslwip/NestedClosure.html">Martin Fowler first coined</a> (as far as I know) and published on his <a href="http://martinfowler.com/dslwip/index.html">DSL WIP</a> site. His formal definition:</p>
<blockquote><p><i>Express statement sub-elements of a function call by putting them into a closure in an argument.</i></p>
</blockquote>
<p>You pass a delegate as a method parameter. The receiving method executes the function represented by that delegate against an object it controls.&nbsp; Nested closure in C# is easy to spot because the delegate is usually typed as <em>Action&lt;T&gt;</em>, where <em>T</em> is the type of the object that the called method will provide as a parameter to our argument function.</p>
<p>The most obvious example is a common extension method:</p>
<pre class="code"><span style="color: blue">public static void </span>ForEach&lt;T&gt;(<span style="color: blue">this </span><span style="color: #2b91af">IEnumerable</span>&lt;T&gt; items, <span style="color: #2b91af">Action</span>&lt;T&gt; action)
{
    <span style="color: blue">foreach </span>(T item <span style="color: blue">in </span>items)
    {
        action(item);
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Nested closure is like <a href="http://www.dofactory.com/Patterns/PatternTemplate.aspx">template method</a>, but instead of deriving from a base class to affect behavior, the additional behavior is provided as an argument.&nbsp; In the same way that template method is great when you want to communicate behavior from derivations to base classes, nested closure works when you want to communicate behavior as you call a method.</p>
<p>Consider working with a common series of steps when writing repository methods against NHibernate:</p>
<pre class="code"><span style="color: blue">public </span><span style="color: #2b91af">Order</span>[] GetAllOpenOrders(<span style="color: #2b91af">Customer </span>customer)
{
    <span style="color: #2b91af">ISession </span>session = GetSession();
    <span style="color: #2b91af">IQuery </span>query = session.CreateQuery(<span style="color: #a31515">"from Order o where o.Resolution is null and o.Customer = ?"</span>);
    query.SetEntity(0, customer);
    <span style="color: blue">var </span>results = query.List&lt;<span style="color: #2b91af">Order</span>&gt;().ToArray();
    <span style="color: blue">return </span>results;
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Code like this &#8211; where you have the same basic structure in several methods &#8211; can be made more terse by using a nested closure.</p>
<pre class="code"><span style="color: blue">public </span><span style="color: #2b91af">Order</span>[] GetShippedOrders(<span style="color: #2b91af">Customer </span>customer)
{
    <span style="color: blue">const string </span>hql = <span style="color: #a31515">"select distinct s.Order from Shipment s where s.Order.Customer = ?"</span>;

    <span style="color: blue">return </span>Hql(hql, x =&gt; x.SetEntity(0, customer));
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The second parameter is an <em>Action&lt;IQuery&gt;</em>.</p>
<pre class="code"><span style="color: blue">protected </span>T[] Hql(<span style="color: blue">string </span>query, <span style="color: #2b91af">Action</span>&lt;<span style="color: #2b91af">IQuery</span>&gt; additionalWork)
{
    <span style="color: #2b91af">IQuery </span>iquery = GetSession().CreateQuery(query);

    <span style="color: blue">if </span>(additionalWork != <span style="color: blue">null</span>)
        additionalWork(iquery);

    <span style="color: blue">return </span>iquery.List&lt;T&gt;().ToArray();
}</pre>
<p>Nested closures are also good for adding fluency to APIs.&nbsp; This is the context of Fowler&#8217;s writing, and you can see it clearly in Rhino Mocks:</p>
<pre class="code">repository.AssertWasCalled(x =&gt; x.Save(<span style="color: blue">null</span>), o =&gt;
    {
        o.IgnoreArguments();
        o.Constraints(<span style="color: #2b91af">Property</span>.AllPropertiesMatch(visitToSave));
    });</pre>
<p>In this scenario we&#8217;re passing a delegate that, when invoked later, helps Rhino Mocks configure options for its expectations.</p>
]]></content:encoded>
			<wfw:commentRss>http://mhinze.com/simple-nested-closure/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>If I Wasn’t Presenting All Day, This Would Be My Austin Code Camp Schedule</title>
		<link>http://mhinze.com/if-i-wasnt-presenting-all-day-this-would-be-my-austin-code-camp-schedule/</link>
		<comments>http://mhinze.com/if-i-wasnt-presenting-all-day-this-would-be-my-austin-code-camp-schedule/#comments</comments>
		<pubDate>Tue, 26 May 2009 23:36:16 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[austin code camp]]></category>

		<guid isPermaLink="false">http://mhinze.com/if-i-wasnt-presenting-all-day-this-would-be-my-austin-code-camp-schedule/</guid>
		<description><![CDATA[I&#8217;m into the idea of a code camp.&#160; So many conferences and presentations I attend are chatty and abstract, it&#8217;ll be good to see Studio and Resharper and keyboard shortcuts and macros and hard core programming fly around on projectors all day. Since I&#8217;m facilitating for six hours, this is a list of sessions that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m into the idea of a code camp.&nbsp; So many conferences and presentations I attend are chatty and abstract, it&#8217;ll be good to see Studio and Resharper and keyboard shortcuts and macros and hard core programming fly around on projectors all day. Since I&#8217;m facilitating for six hours, this is a list of sessions that I&#8217;m distraught to miss at <a href="http://adnug.org/AustinCodeCamp09">Austin Code Camp</a>:</p>
<ul>
<li><em>9:00 AM</em> <strong>Git for people</strong> by <a href="http://www.lostechies.com/blogs/joe_ocampo/">Joe Ocampo</a>.&nbsp; <br />I just want to see someone fly through using this so I can upgrade my understanding from novice to .. post-novice. Hopefully some msysgit tricks for the Windows crowd. Can someone record this?
<li><em>10:00 AM</em> <a href="http://www.lostechies.com/blogs/hex/">Eric Hexter</a>&#8217;s talk on <strong>Project Automation &#8211; Learn about Build and Deployment Automation<br /></strong>Eric is a master on the subject and I&#8217;d love to glean some tidbits from his repertoire.
<li><em>11:00 AM </em><strong>A Handful of Things You Can Do In Ruby That Scares the Pants Off of C# Developers</strong> by <a href="http://blog.scottbellware.com/">Scott Bellware</a><br />I&#8217;m at least wary of dynamic languages (in the large), and I&#8217;m sure Scott will challenge my (mis)understandings.&nbsp; Also hoping for a recording.
<li><em>12:45 PM </em><strong>Enterprise Architecture Patterns: Presentation, Business Logic, and Persistence </strong>by <a href="http://www.lostechies.com/blogs/chad_myers/">Chad Myers</a> and <a href="http://www.lostechies.com/blogs/johnteague/">John Teague</a><br />I <em>will</em> make it to this session, at least in part.. I know enough to know that there&#8217;s so much I don&#8217;t know.&nbsp; This one will be all about information literacy.
<li><em>2:45 PM</em> <strong>Test Driven JavaScript </strong>by John Teague<br />I hope John shows me a better way.. because mine is not frictionless.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mhinze.com/if-i-wasnt-presenting-all-day-this-would-be-my-austin-code-camp-schedule/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Austin Code Camp</title>
		<link>http://mhinze.com/austin-code-camp/</link>
		<comments>http://mhinze.com/austin-code-camp/#comments</comments>
		<pubDate>Mon, 25 May 2009 17:57:55 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[austin code camp]]></category>

		<guid isPermaLink="false">http://mhinze.com/austin-code-camp/</guid>
		<description><![CDATA[I&#8217;ll facilitate two sessions at Austin Code Camp on May 30th.
The first is called Take It For A Test Drive &#8211; clearly a failed attempt at a witty name for a hands-on-keyboard workshop where participants will design and implement a new feature for CodeCampServer, an open source ASP.NET MVC project.&#160; We&#8217;ll get our hands on [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll facilitate two sessions at <a href="http://adnug.org/AustinCodeCamp09">Austin Code Camp</a> on May 30th.</p>
<p>The first is called <strong>Take It For A Test Drive</strong> &#8211; clearly a failed attempt at a witty name for a hands-on-keyboard workshop where participants will design and implement a new feature for <a href="http://codecampserver.org">CodeCampServer</a>, an open source ASP.NET MVC project.&nbsp; We&#8217;ll get our hands on NHibernate, TDD, Rhino Mocks, Resharper.. and maybe some ASP.NET MVC (although I&#8217;m hoping that we touch the UI as little as possible since that stuff tends to slow workshops like this).</p>
<p>Here&#8217;s the abstract:</p>
<blockquote><p>Conception, design, tasking, testing, construction. We&#8217;ll do it all by building a new feature into a .NET open source enterprise software application. We&#8217;ll design as a team, test-drive the implementation, and use the tools that enable us to move fast. This is a hands-on, no holds barred opportunity to get down and dirty with TDD. Bring your laptop with required software installed: Visual Studio .NET 2008, TestDriven.NET, TortoiseSVN, Resharper 4.5, SQL Server 2005 Express with mixed mode authentication</p>
</blockquote>
<p>It&#8217;s<strong> <em>really important</em></strong> that participants bring their laptops with all the software installed.&nbsp; If you can <a href="http://code.google.com/p/codecampserver/source/browse/trunk/README.txt">build Code Camp Server locally</a> and load the solution in Visual Studio, you&#8217;re golden.&nbsp; This isn&#8217;t a presentation, it&#8217;s a workshop.</p>
<p>So here&#8217;s how it will go down:</p>
<ul>
<li>A 15-20 minute warm-up that involves checking out the source code and building it locally.
<li>I&#8217;ll do a quick (very quick) rundown of the project and demo some Resharper stuff.
<li>I&#8217;ll do another very quick intro to TDD if necessary.
<li>Then I&#8217;ll present the specifications for the new feature and the participants will hash out the requirements with me as I role-play a product owner.
<li>As a team we&#8217;ll use pseudo-UML and sequence diagrams to figure out exactly what we&#8217;ll be doing and we&#8217;ll task it out step by step.
<li>Then we&#8217;ll go heads down and implement the feature.&nbsp; I&#8217;ll speak up and code on a projector at reasonable intervals.</li>
</ul>
<p>It&#8217;s a commitment to attend this one &#8211; you&#8217;ll dedicate most of the morning to a workshop.&nbsp; But if you are where I was a couple years ago &#8211; familiar with C# and most of the tools but needing help getting started with TDD and other techniques, I think you&#8217;ll like this session.</p>
<p>In the afternoon I&#8217;ll present my<strong> </strong><a href="http://mhinze.com/practical-ioc-slides-and-code/"><strong>Practical IOC</strong></a> talk.&nbsp; This one is a presentation. </p>
<p>Here&#8217;s the abstract: </p>
<blockquote><p>From the basics to interesting, more advanced usage scenarios, we&#8217;ll discover how inversion of control can give life to object oriented principles and enable higher quality and faster delivery.</p>
</blockquote>
<p>I&#8217;d say it&#8217;s intermediate level subject matter.&nbsp; I have modified it a little since I presented it last.&nbsp; This one is a few (awesome!) slides and then me coding through usage scenarios.</p>
<p>Hope to see you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://mhinze.com/austin-code-camp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome Eric Anderson</title>
		<link>http://mhinze.com/welcome-eric-anderson/</link>
		<comments>http://mhinze.com/welcome-eric-anderson/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 21:09:51 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[headspring]]></category>

		<guid isPermaLink="false">http://mhinze.com/welcome-eric-anderson/</guid>
		<description><![CDATA[Today at Headspring we&#8217;re pleased to have Eric Anderson on board.&#160; Eric&#8217;s been hanging around the Austin agile software development community for a few years, and he&#8217;s been to many of the ALT.NET conferences, including the last one in Seattle.&#160; It&#8217;s exciting to see the company grow in the right direction&#8230; welcome Eric!
]]></description>
			<content:encoded><![CDATA[<p>Today at <a href="http://headspringsystems.com/">Headspring</a> we&#8217;re pleased to have <a href="http://testinfected.blogspot.com/">Eric Anderson</a> on board.&nbsp; Eric&#8217;s been hanging around the Austin agile software development community for a few years, and he&#8217;s been to many of the ALT.NET conferences, including the last one in Seattle.&nbsp; It&#8217;s exciting to see the company grow in the right direction&#8230; welcome Eric!</p>
]]></content:encoded>
			<wfw:commentRss>http://mhinze.com/welcome-eric-anderson/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SubControllers and ViewModel</title>
		<link>http://mhinze.com/subcontrollers-and-viewmodel/</link>
		<comments>http://mhinze.com/subcontrollers-and-viewmodel/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 01:23:46 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[viewmodel]]></category>

		<guid isPermaLink="false">http://mhinze.com/subcontrollers-and-viewmodel/</guid>
		<description><![CDATA[SubControllers solved a big problem for us when we first started our current project.&#160; I posted about them back in the day.
The problem was isolating authorization to view sections of a page.&#160; In other words, if you didn&#8217;t have permission X, you couldn&#8217;t see the top-left section of the screen.&#160; If you didn&#8217;t have permission [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://groups.google.com/group/mvccontrib-discuss/browse_thread/thread/b050e21fe322c08a#">SubControllers</a> solved a big problem for us when we first started our current project.&nbsp; I <a href="http://mhinze.com/tag/subcontrollers/">posted about them</a> back in the day.</p>
<p>The problem was isolating authorization to view sections of a page.&nbsp; In other words, if you didn&#8217;t have permission X, you couldn&#8217;t see the top-left section of the screen.&nbsp; If you didn&#8217;t have permission Y, you couldn&#8217;t see top-right section of the screen.&nbsp; By composing the controllers that decided how to display the sections, we could test drive nicely each controller&#8217;s authorization check and subsequent decision.</p>
<p>Later we embraced the ViewModel concept and are working with strongly-typed views.&nbsp; We found that using SubControllers wasn&#8217;t the best approach in that situation, for a couple reasons: </p>
<p>First, that the view properly invokes the SubController remains untested.&nbsp; The responsibility for performing the interaction still rests with the view.&nbsp; So why not just make the authorization check in the view?&nbsp; </p>
<p>That&#8217;s the other problem: scattered partial views can be a small maintenance headache.&nbsp; In our current project, after embracing the ViewModel, there just wasn&#8217;t a pain that SubControllers cured.</p>
<p>We didn&#8217;t abandon SubControllers because they didn&#8217;t work, or because there was a flaw in the implementation, or because they were too complex, or anything like that.&nbsp; They may still be the right approach for a given screen.</p>
<p>If you&#8217;re unsure how to share view pieces in your application, refer to <a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/01/27/asp-net-mvc-options-for-consolidating-html.aspx">Jimmy&#8217;s excellent guide</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mhinze.com/subcontrollers-and-viewmodel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
