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

<channel>
	<title>Wizards of Smart &#187; Patterns</title>
	<atom:link href="http://wizardsofsmart.net/category/patterns/feed/" rel="self" type="application/rss+xml" />
	<link>http://wizardsofsmart.net</link>
	<description>.NET Design Patterns</description>
	<lastBuildDate>Thu, 29 Jul 2010 16:40:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0-beta2-14896</generator>
		<item>
		<title>Decorator Revisited</title>
		<link>http://wizardsofsmart.net/patterns/decorator-revisited-2/</link>
		<comments>http://wizardsofsmart.net/patterns/decorator-revisited-2/#comments</comments>
		<pubDate>Wed, 26 May 2010 07:17:56 +0000</pubDate>
		<dc:creator>panesofglass</dc:creator>
				<category><![CDATA[Patterns]]></category>

		<guid isPermaLink="false">http://wizardsofsmart.net/?p=335</guid>
		<description><![CDATA[I learned a few things about my decorator implementation last week from awhile back: 1) make sure your tests are good tests and 2) you cannot decorate methods called in a class called by other decorated methods (aside from using local Funcs for method implementations, which I will describe in another post). First things first, [...]]]></description>
			<content:encoded><![CDATA[<p>I learned a few things about my decorator implementation <del datetime="2010-05-26T06:31:00+00:00">last week</del> <a href="http://wizardsofsmart.net/patterns/refactoring-with-the-decorator-pattern/">from awhile back</a>: 1) make sure your tests are good tests and 2) you cannot decorate methods called in a class called by other decorated methods (aside from using local Funcs for method implementations, which I will describe in another post).</p>
<p>First things first, how did I catch the mistake? These were my tests, including the one that caught the issue:<br />
<script src="http://gist.github.com/414141.js"></script></p>
<p>I was only receiving the start and end events and no others. To fix my mistakes, I ended up with two interfaces from my original interface so that I could appropriately apply my decorators:<br />
<script src="http://gist.github.com/414144.js"></script></p>
<p>However, this is now getting ridiculous. Nevertheless, deadlines were coming up, and I persevered. You&#8217;ll have noticed also that my api changed slightly. Instead of passing in the path and calling a static method on SpreadsheetDocument, I&#8217;m now passing in the SpreadsheetDocument. Much nicer for testing, especially since <code>.Rows()</code> is already my own extension method. I also have a public property for the item loader on the detail loader. I&#8217;m not thoroughly impressed, but it works.</p>
<p>Once I updated my tests:<br />
<script src="http://gist.github.com/414164.js"></script></p>
<p>and my implementations (note that my FakeDetailLoader became the implementation of FakeDetailItemLoader and DetailLoader is no longer an ugly abstract base class):<br />
<script src="http://gist.github.com/414165.js"></script></p>
<p>Maybe you can now see why it&#8217;s taken me awhile to post this. It wasn&#8217;t difficult, but it sure was tedious, and a little ugly. I&#8217;m not sure it was worthy it for this simple demo, and I wasn&#8217;t sure on my project. I was later proved right, however, when we kept receiving increasingly complex requirements. Decorator to the rescue!</p>
]]></content:encoded>
			<wfw:commentRss>http://wizardsofsmart.net/patterns/decorator-revisited-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Refactoring with the Decorator Pattern</title>
		<link>http://wizardsofsmart.net/patterns/refactoring-with-the-decorator-pattern/</link>
		<comments>http://wizardsofsmart.net/patterns/refactoring-with-the-decorator-pattern/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 17:39:15 +0000</pubDate>
		<dc:creator>panesofglass</dc:creator>
				<category><![CDATA[Patterns]]></category>
		<category><![CDATA[Decorator]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Prism]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[Visitor]]></category>

		<guid isPermaLink="false">http://wizardsofsmart.net/patterns/refactoring-with-the-decorator-pattern/</guid>
		<description><![CDATA[If you are wondering what happened to my flame-war-instigating series on the problems with MVC, you’ll have to continue waiting (as will I for the flame war, apparently). I’ve been busy and haven’t had the time to finish typing and inserting links into the rest of the posts. Such is life. In the meantime, I [...]]]></description>
			<content:encoded><![CDATA[<p>If you are wondering what happened to my flame-war-instigating series on the problems with MVC, you’ll have to continue waiting (as will I for the flame war, apparently). I’ve been busy and haven’t had the time to finish typing and inserting links into the rest of the posts. Such is life.</p>
<p>In the meantime, I hope to start emphasizing the usefulness of developing with patterns. This post was inspired by <a href="http://www.lostechies.com/blogs/sean_chambers/" target="_blank" onclick="urchinTracker('/outgoing/www.lostechies.com/blogs/sean_chambers/?referer=');">Sean Chambers</a> recent <a href="http://www.lostechies.com/blogs/sean_chambers/archive/2009/07/31/31-days-of-refactoring.aspx" target="_blank" onclick="urchinTracker('/outgoing/www.lostechies.com/blogs/sean_chambers/archive/2009/07/31/31-days-of-refactoring.aspx?referer=');">31 Days of Refactoring</a> (<a href="http://www.lostechies.com/media/p/27197/download.aspx" target="_blank" onclick="urchinTracker('/outgoing/www.lostechies.com/media/p/27197/download.aspx?referer=');">e-book</a>) and my recent flub when trying to describe the <a href="http://www.dofactory.com/Patterns/PatternDecorator.aspx" target="_blank" onclick="urchinTracker('/outgoing/www.dofactory.com/Patterns/PatternDecorator.aspx?referer=');">Decorator</a> pattern (ducks, really?).</p>
<h3>Setting the Stage</h3>
<p>On a recent project using WPF and <a href="http://compositewpf.codeplex.com" target="_blank" onclick="urchinTracker('/outgoing/compositewpf.codeplex.com?referer=');">Prism</a>, we’ve built business layer objects to import and export text and Excel files in batches. These batch processes included importing data, transforming the data into something useful, and persisting the transformed data into our database. We needed to communicate progress back to the UI for each of these tasks to keep the user aware of progress, as these tasks can take quite a long time, especially with multiple files. The initial design was raw and messy with lots of code duplication to explicitly create a BackgroundWorker directly within each ViewModel to start the import/export process and listen for events fired directly from our business objects (which essentially follow the <a href="http://www.martinfowler.com/eaaCatalog/transactionScript.html" target="_blank" onclick="urchinTracker('/outgoing/www.martinfowler.com/eaaCatalog/transactionScript.html?referer=');">Transaction Script pattern</a>, more or less).</p>
<p><a href="http://wizardsofsmart.net/author/rookieone" target="_blank">Another co-worker</a>, when he was tasked with building another importer, created a subclass of our base ViewModel class and added all the BackgroundWorker plumbing, then did the same for our base business object class. He also created a ProgressItem : INotifyPropertyChanged type with methods to Start(int items), StartAsIndeterminate, IncrementProgress, EndWithSuccess, and EndWithFailure. He also added a collection wrapper for ProgressItems to allow ease of registering and auto-subscribing (through the AutoNotify method) the owning business object to the PropertyChanged events of the ProgressItems. With this setup, the UI ViewModel could listen to the PropertyChanged events of the business object’s ProgressItems instead of having the business object fire its own events. As you can imagine, this made implementing a batch import / export process immensely easier.</p>
<p>I eventually went back and refactored all of our existing business objects and ViewModels to follow this approach. Not only are both the business objects and ViewModels easier to debug, they are also easier to test since we are no longer firing events, just updating the state of a given ProgressItem. Well, sort of….</p>
<h3>My Turn</h3>
<p>I was recently tasked with creating a new batch import process to pull data from Excel. I started by following the pattern <a href="http://wizardsofsmart.net/author/rookieone" target="_blank">JB</a> set up and had the initial steps of my batch import object ready to go. (I also confess to not having written any tests yet because, to date, we hadn’t figured out how to mock out the SpreadsheetDocument, Rows, etc. from the Open XML SDK we’re using to assist in our import / export tasks. I’ve now solved that problem and retro-fitted in unit tests. I’ll post that solution later.)</p>
<h4>Identifying the Problem</h4>
<p>After taking a step back to look at what I had done, I quickly realized that I was violating <abbr title="Single Responsibility Principle"><a href="http://www.objectmentor.com/resources/articles/srp.pdf" target="_blank" onclick="urchinTracker('/outgoing/www.objectmentor.com/resources/articles/srp.pdf?referer=');">SRP</a></abbr> with the inclusion of the ProgressItems in each step. Some might think that’s not such a big deal; after all, calling start, increment, and end on a single object is only three lines, which doesn’t seem like a lot. However, multiply those three lines by the number of import/export objects and factor in the number of times we forget just one of the them, and you begin to appreciate removing the extraneous bits.</p>
<p>I’m quite certain I noticed this primarily because of my study of functional programming rather than any object-oriented pattern literature I’ve come across. Nevertheless, I considered only OO patterns for the solution simply because the alternative was likely a monad, and that just scares the pants off of most people. (And I like my co-workers.)</p>
<h4>The Contenders</h4>
<p>I needed something that could pull the ProgressItem out of my actual import procedure and allow me to focus that logic purely on the import. The two patterns that came to mind were the <a href="http://www.dofactory.com/Patterns/PatternDecorator.aspx" target="_blank" onclick="urchinTracker('/outgoing/www.dofactory.com/Patterns/PatternDecorator.aspx?referer=');">Decorator</a> and the <a href="http://en.wikipedia.org/wiki/Visitor_pattern" target="_blank" onclick="urchinTracker('/outgoing/en.wikipedia.org/wiki/Visitor_pattern?referer=');">Visitor</a>.</p>
<p>The <a href="http://www.dofactory.com/Patterns/PatternDecorator.aspx" target="_blank" onclick="urchinTracker('/outgoing/www.dofactory.com/Patterns/PatternDecorator.aspx?referer=');">Decorator</a> is generally considered (well, at least by the people I know) the simpler of the two. It wraps and extends an object without changing the underlying object and still providing the same interface. Examples include “decorating” coffee with sugar, cream, etc. and returning an adjusted price for the additional “decorations.”</p>
<p>The <a href="http://en.wikipedia.org/wiki/Visitor_pattern" target="_blank" onclick="urchinTracker('/outgoing/en.wikipedia.org/wiki/Visitor_pattern?referer=');">Visitor</a>, on the other hand, is passed into an object’s <code>void Accept(Visitor visitor)</code> method and provides some resulting side-effect through the visitor itself. Examples include pretty printing, which print a tree-structure with the appropriate indentation, or adding the appropriate tax to an order. Another example for those using the System.Expression namespace would be using the <a href="http://msdn.microsoft.com/en-us/library/bb882521.aspx" target="_blank" onclick="urchinTracker('/outgoing/msdn.microsoft.com/en-us/library/bb882521.aspx?referer=');">ExpressionVisitor</a> to allow the use of <abbr title="Plain Old CLR Objects">POCO</abbr> objects with Entity Framework v1, as <a href="http://wizardsofsmart.net/author/rookieone" target="_blank">JB</a> demonstrated <a href="http://greekfire.codeplex.com/SourceControl/changeset/view/22088#367262" target="_blank" onclick="urchinTracker('/outgoing/greekfire.codeplex.com/SourceControl/changeset/view/22088_367262?referer=');">here</a>. (For those familiar with monads, you’ll likely see some resemblance.)</p>
<p>In this case, I had the following interface:</p>
<script src="http://gist.github.com/217644.js"></script>
<p>For reference, the initial state of a Loader looked something like this, making adjustments to the method signatures for the addition of the ProgressItem, which initially was passed to each method:</p>
<script src="http://gist.github.com/217648.js"></script>
<h4>Enter the Decorator</h4>
<p>Instead of muddying my interface with a <code>void Accept(Visitor vistor)</code> method, I chose to just decorate it. My resulting decorated class looked as follows:</p>
<script src="http://gist.github.com/217649.js"></script>
<p>The resulting base DetailLoader looked like so:</p>
<script src="http://gist.github.com/217651.js"></script>
<p>This made the loader much easier to reason about and test thoroughly, as the ProgressItem is completely removed. I no longer have to remember to add the calls to it or even bother with anything other than loading data. Again, I know some will probably call this an over-engineered example, but as a developer who has had to debug these things when they were initially one method directly on the business object not firing a particular event, the additional abstractions make this a breeze to create, debug, and test. To each his own.</p>
<h4>Testing</h4>
<p>As I mentioned, I figured out a way to test this against the Open XML SDK, but since this is already quite a long post, I’ll postpone that for later. I hope you find this a helpful explanation of how and when to refactor using the <a href="http://www.dofactory.com/Patterns/PatternDecorator.aspx" target="_blank" onclick="urchinTracker('/outgoing/www.dofactory.com/Patterns/PatternDecorator.aspx?referer=');">Decorator</a> pattern. Please let me know if you have any feedback on the matter.</p>
]]></content:encoded>
			<wfw:commentRss>http://wizardsofsmart.net/patterns/refactoring-with-the-decorator-pattern/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Duct Tape AND Quality Together</title>
		<link>http://wizardsofsmart.net/patterns/duct-tape-and-quality-together/</link>
		<comments>http://wizardsofsmart.net/patterns/duct-tape-and-quality-together/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 18:00:00 +0000</pubDate>
		<dc:creator>panesofglass</dc:creator>
				<category><![CDATA[Patterns]]></category>
		<category><![CDATA[CQS]]></category>
		<category><![CDATA[DDDD]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Domain Driven Design]]></category>
		<category><![CDATA[Duct Tape Programmer]]></category>
		<category><![CDATA[software craftsmanship]]></category>
		<category><![CDATA[SOLID]]></category>

		<guid isPermaLink="false">http://wizardsofsmart.net/patterns/dogs-and-cats-living-together/</guid>
		<description><![CDATA[You’ve probably read Joel’s post on The Duct Tape Programmer and several responses. I did not like Joel’s post at first, as I thought it far too general and easily taken in the context of “always do it this way.” For the record, I have no problems with the duct tape approach when trying something [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_248" class="wp-caption aligncenter" style="width: 310px"><img class="size-full wp-image-248" title="cats-dogs-together-760114-300x225" src="http://wizardsofsmart.net/wp/wp-content/uploads/2009/10/cats-dogs-together-760114-300x225.jpg" alt="Dogs and Cats Living Together" width="300" height="225" /><p class="wp-caption-text">Dogs and Cats Living Together</p></div>
<p>You’ve probably read Joel’s post on <a href="http://www.joelonsoftware.com/items/2009/09/23.html" target="_blank" onclick="urchinTracker('/outgoing/www.joelonsoftware.com/items/2009/09/23.html?referer=');">The Duct Tape Programmer</a> and <a href="http://www.bing.com/search?setmkt=en-US&amp;q=duct+tape+programmer" target="_blank" onclick="urchinTracker('/outgoing/www.bing.com/search?setmkt=en-US_amp_q=duct+tape+programmer&amp;referer=');">several responses</a>. I did not like Joel’s post at first, as I thought it far too general and easily taken in the context of “always do it this way.” For the record, I have no problems with the duct tape approach when trying something out, but I’ve been burned when having to work on someone else’s let-me-try-this project that then became a core, production system. That’s a formula for PAIN. That said, I think you can make a case for using a duct tape approach for some, small parts of your application.</p>
<p>This past week I put together a presentation on <abbr title="Domain Driven Design"><a href="http://www.domaindrivendesign.org" target="_blank" onclick="urchinTracker('/outgoing/www.domaindrivendesign.org?referer=');">DDD</a></abbr> for my office. I included some slides describing <abbr title="Distributed Domain Driven Design">DDDD</abbr> and <abbr title="Command Query Separation">CQS</abbr> as <a href="http://codebetter.com/blogs/gregyoung/" target="_blank" onclick="urchinTracker('/outgoing/codebetter.com/blogs/gregyoung/?referer=');">Greg Young</a> has discussed time and again. While I put together those slides and thinking about Bounded Contexts, I had a sudden realization that even within a single Bounded Context or Module, you could mix duct tape with quality when using CQS.</p>
<p style="text-align: center;"><img class="size-full wp-image-250 aligncenter" title="CQS" src="http://wizardsofsmart.net/wp/wp-content/uploads/2009/10/CQS.jpg" alt="CQS" width="218" height="224" /></p>
<p>If you look at the diagram above, you can easily see where this is possible. If you split your module into read and write contexts, you can focus your greatest efforts for quality on the write side, where your domain lives, and leave the ever-changing read side to duct tape, RAD, etc. for displaying in the UI or reporting. The idea here is that you will often find that what you need to persist doesn’t change very much, but what you are asked to display changes nearly constantly. That’s at least my experience.</p>
<p>Another benefit to this approach is on the sales pipeline. Creating applications consists of these two parts: reading and writing. You may find that clients who have their own internal developers may not want to hire a consultant or contracting firm to build an entire app at their normal rates, but if you can provide them the write side and architecture guidance for the rest of the app, you may be able to sell more projects and keep your people happy working on quality code and quality projects. Of course, that’s just theory at this point.</p>
<p>So is this a case of “mass hysteria”? I don’t know. I like the idea, if not so much for the inclusion of duct tape as the possibility of limiting changes to the core domain models in an application architecture. I’m curious to know what others think or have done.</p>
]]></content:encoded>
			<wfw:commentRss>http://wizardsofsmart.net/patterns/duct-tape-and-quality-together/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Houston Techfest</title>
		<link>http://wizardsofsmart.net/patterns/houston-techfest/</link>
		<comments>http://wizardsofsmart.net/patterns/houston-techfest/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 04:40:58 +0000</pubDate>
		<dc:creator>rookieone</dc:creator>
				<category><![CDATA[Patterns]]></category>

		<guid isPermaLink="false">http://wizardsofsmart.net/patterns/houston-techfest/</guid>
		<description><![CDATA[JB here… Wow! Techfest was lots of fun! I got the chance to see and talk to a lot of my friends who I haven’t seen in awhile. Also, it was nice to be finally finished with my two presentations. Both were fun but I will admit to liking my Evolve Your Code material a [...]]]></description>
			<content:encoded><![CDATA[<p>JB here… Wow! Techfest was lots of fun! I got the chance to see and talk to a lot of my friends who I haven’t seen in awhile. </p>
<p>Also, it was nice to be finally finished with my two presentations. Both were fun but I will admit to liking my Evolve Your Code material a bit more than the WPF Input Validation. They were both a lot of work. Be sure to thank presenters. I knew work went into the presentations but I didn’t appreciate how much until I tried to do two. I learned a lesson with that decision. Never do 2 new presentations. It’s way too much work and both suffer from neglect. I will write a post on all my presentation lessons later.</p>
<p>Without the 2 presentations looming over me and my new job, I should be able to get back to blogging more. I love sharing what I know, even if its just to myself months from now when I forget everything. <img src='http://wizardsofsmart.net/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>For the slides I am trying out slideshare and am also using Git Hub for the slides and solutions.</p>
<h4>Evolve Your Code:</h4>
<p><a title="http://www.slideshare.net/RookieOne/evolve-your-code" href="http://www.slideshare.net/RookieOne/evolve-your-code" onclick="urchinTracker('/outgoing/www.slideshare.net/RookieOne/evolve-your-code?referer=');">http://www.slideshare.net/RookieOne/evolve-your-code</a></p>
<p><a title="http://github.com/RookieOne/Evolve-Your-Code" href="http://github.com/RookieOne/Evolve-Your-Code" onclick="urchinTracker('/outgoing/github.com/RookieOne/Evolve-Your-Code?referer=');">http://github.com/RookieOne/Evolve-Your-Code</a></p>
<p>&#160;</p>
<h4>WPF Input Validation:</h4>
<p><a title="http://www.slideshare.net/RookieOne/wpf-validation" href="http://www.slideshare.net/RookieOne/wpf-validation" onclick="urchinTracker('/outgoing/www.slideshare.net/RookieOne/wpf-validation?referer=');">http://www.slideshare.net/RookieOne/wpf-validation</a></p>
<p><a title="http://github.com/RookieOne/WPF-Input-Validation" href="http://github.com/RookieOne/WPF-Input-Validation" onclick="urchinTracker('/outgoing/github.com/RookieOne/WPF-Input-Validation?referer=');">http://github.com/RookieOne/WPF-Input-Validation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wizardsofsmart.net/patterns/houston-techfest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A History of Violence against HTML</title>
		<link>http://wizardsofsmart.net/patterns/a-history-of-violence-against-html/</link>
		<comments>http://wizardsofsmart.net/patterns/a-history-of-violence-against-html/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 19:17:21 +0000</pubDate>
		<dc:creator>panesofglass</dc:creator>
				<category><![CDATA[Patterns]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PresentationModel]]></category>
		<category><![CDATA[ViewModel]]></category>
		<category><![CDATA[Web Application]]></category>

		<guid isPermaLink="false">http://wizardsofsmart.net/?p=223</guid>
		<description><![CDATA[[This is the second in a series on the use of MVC for building web "applications".] HTML was designed as a document format with hypermedia connections to other, related documents. Today, however, we abuse HTML and treat it as an application platform. It somehow performs remarkably well in most cases. I suppose that’s a testament to [...]]]></description>
			<content:encoded><![CDATA[<p>[This is the second in a <a title="The Problem with the MVC Frameworks" href="http://wizardsofsmart.net/patterns/the-problem-with-the-mvc-frameworks-introduction/">series</a> on the use of MVC for building web "applications".]</p>
<p><span>HTML</span> was designed as a document format with hypermedia connections to other, related documents. Today, however, we abuse <span>HTML</span> and treat it as an application platform. It somehow performs remarkably well in most cases. I suppose that’s a testament to the agility of declarative markup. Nevertheless, I think we could all agree that <span>HTML</span> at least <em>started</em> life as a document format. If this is the case, I argue that <span>HTML</span> is not a view format; rather it is a serialization format for a model.</p>
<p>I’m sure many reading this are probably calling me a fool or worse. Well, don’t take my word for it. Let’s look at what some of the leading web developer/designers are saying:</p>
<blockquote><p>In markup, semantics is concerned with the meaning of an element and how that element describes the content it contains.<br />
-Molly E. Holzschlag (<a href="http://www.informit.com/articles/article.asp?p=369225&amp;rl=1" onclick="urchinTracker('/outgoing/www.informit.com/articles/article.asp?p=369225_amp_rl=1&amp;referer=');">http://www.informit.com/articles/article.asp?p=369225&amp;rl=1</a>)</p></blockquote>
<blockquote><p>Although it might be tempting to use the visual layout as the basis for the structure of your markup, this could lead to you overusing elements, particularly <code>&lt;div&gt;</code> elements. This will also result in establishing your content order primarily to accomplish the visual layout rather than it making sense when no style sheets are available. <strong>To avoid presentational markup and ordering problems, begin by first looking at the content and then working out from the meaning</strong>(emphasis mine).<br />
-Andy Clarke (<a href="http://www.transcendingcss.com/" onclick="urchinTracker('/outgoing/www.transcendingcss.com/?referer=');">Transcending <span>CSS</span></a>)</p></blockquote>
<blockquote><p>The notion that HTML is a display language has been proven long ago to be a <a title="Definition of 'Bad Thing' in the Jargon File." href="http://catb.org/jargon/html/B/Bad-Thing.html" onclick="urchinTracker('/outgoing/catb.org/jargon/html/B/Bad-Thing.html?referer=');">Bad Thing</a>. CSS taught us to separate our presentation from our content, and the doors that opened when we did it were invaluable. Today, however, we’re still delivering web applications as HTML documents with a bit of scripting layered on top. This works, but is strangled by all of HTML’s limitations. Fundamentally, <strong>HTML is not an application delivery format, it is a content description language</strong>, despite the <a href="http://www.sitepoint.com/blogs/2008/11/25/w3c-markup-validation-service-adds-experimental-html5-support/" onclick="urchinTracker('/outgoing/www.sitepoint.com/blogs/2008/11/25/w3c-markup-validation-service-adds-experimental-html5-support/?referer=');">valiant efforts of the HTML5 Working Group</a>.<br />
- Meitar Moscovitz (<a href="http://www.sitepoint.com/blogs/2008/12/22/svg-is-the-future-of-application-development/" onclick="urchinTracker('/outgoing/www.sitepoint.com/blogs/2008/12/22/svg-is-the-future-of-application-development/?referer=');">SVG Is The Future Of Application Development</a>)</p></blockquote>
<p>No, I can’t quote them directly, but I believe my argument has the same spirit. We should look at <span>HTML</span> as a PresentationModel, or ViewModel if you prefer, in the client (i.e. the browser). Therefore, <span>HTML</span> be treated as a serialization of your object model into a document format.</p>
<p>What then is the view? What’s the controller? These are excellent questions. Let’s think about how MVC works. The controller is responsible for receiving requests and relaying responses. The view is supposed to display the representation of the model. For the web, the controller easily aligns with the <span>HTTP</span> protocol and the view to the styles, transforms, and behaviors applied to the model (our <span>HTML</span> document). (I’ve used styles and transforms here separately to emphasize the potential use of <span>XSLT</span> stylesheets in addition to <span>CSS</span>.) Sure, using a document serialization, you could just display the model directly, and the confusion of <span>HTML</span> is here emphasized. It’s a model built out like a visual representation.</p>
<p>Are there some exceptions to this? Sure. If you want to treat <span>HTML</span> as a purely view format, then you can eliminate everything from your <span>HTML</span> except for JavaScript bindable areas and use <span>JSON</span> objects as your PresentationModels. Pass some of those around instead of <span>HTML</span>, and you’re really treating <span>HTML</span> like a true view. However, we don’t generally do that. We usually serialize the model into the <span>HTML</span> and apply our view aspects afterward via <span>CSS</span> and JavaScript.</p>
<p>If we really want to get serious about making an excellent MVC framework, we have to recognize and use our building blocks appropriately. <span>HTML</span> is a model serialization format. Treat it as such.</p>
]]></content:encoded>
			<wfw:commentRss>http://wizardsofsmart.net/patterns/a-history-of-violence-against-html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fluent Interfaces: How Far is Too Far?</title>
		<link>http://wizardsofsmart.net/patterns/fluent-interfaces-how-far-is-too-far/</link>
		<comments>http://wizardsofsmart.net/patterns/fluent-interfaces-how-far-is-too-far/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 15:12:01 +0000</pubDate>
		<dc:creator>panesofglass</dc:creator>
				<category><![CDATA[Patterns]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[fluent interface]]></category>

		<guid isPermaLink="false">http://wizardsofsmart.net/patterns/fluent-interfaces-how-far-is-too-far/</guid>
		<description><![CDATA[Humor me a moment. I know I’ve promised a series on REST/HTTP/HTML that will likely drive everyone nuts, but I had a thought this morning that is probably more bizarre than many others I’ve had. I have really enjoyed building and using fluent interfaces for tools I’m using. I think they can make the code [...]]]></description>
			<content:encoded><![CDATA[<p>Humor me a moment. I know I’ve promised a series on REST/HTTP/HTML that will likely drive everyone nuts, but I had a thought this morning that is probably more bizarre than many others I’ve had. I have really enjoyed building and using fluent interfaces for tools I’m using. I think they can make the code both more readable and maintainable, though the approach differs from more traditional approaches. I’ve recently been working on a fluent interface for creating Atom items and feeds using the <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.aspx" target="_blank" onclick="urchinTracker('/outgoing/msdn.microsoft.com/en-us/library/system.servicemodel.syndication.aspx?referer=');">System.ServiceModel.Syndication</a> namespace, and that has been both frustrating and fun.</p>
<p>This morning, however, I had the thought of creating a fluent interface for one of the most simple of concepts used in .NET: collections. What’s wrong with collections you ask? Nothing really. But what if instead of reading
<pre class="brush: csharp">collection.Add(item)</pre>
<p> you could read
<pre class="brush: csharp">Add.the(item).to(collection)</pre>
<p>? Which is more readable? In the end, that’s similar to what I’m doing with the <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.aspx" target="_blank" onclick="urchinTracker('/outgoing/msdn.microsoft.com/en-us/library/system.servicemodel.syndication.aspx?referer=');">System.ServiceModel.Syndication</a> bit, except that you don’t generally just add one or a few things to the collection in the syndication example. We could create something similar to add and remove events, all using a single static Add/Remove class with various, overloaded methods for the common identification operations.</p>
<p>Is this overkill? As JB mentioned to me over IM, it’s relative. For some, I’m sure you will think I’m nuts. Others may think I am on to something. I don’t think I would go and do it for no reason at all, but if I ended up with some crazy list creation or end-user-wants-to-read-my-code scenarios, I might consider something like that. What do you think?</p>
]]></content:encoded>
			<wfw:commentRss>http://wizardsofsmart.net/patterns/fluent-interfaces-how-far-is-too-far/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MVVM &#8211; The no code behind challenge</title>
		<link>http://wizardsofsmart.net/patterns/mvvm-the-no-code-behind-challenge-2/</link>
		<comments>http://wizardsofsmart.net/patterns/mvvm-the-no-code-behind-challenge-2/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 04:27:05 +0000</pubDate>
		<dc:creator>rookieone</dc:creator>
				<category><![CDATA[Patterns]]></category>
		<category><![CDATA[Samples]]></category>

		<guid isPermaLink="false">http://wizardsofsmart.net/patterns/mvvm-the-no-code-behind-challenge-2/</guid>
		<description><![CDATA[Glenn Block has an excellent post titled “The spirit of MYYM, it’s not a code counting exercise”. The post can be found at CodeBetter. I thoroughly enjoyed the post and greatly appreciate practical discussions on WPF/SL application patterns. I am a bit of a WPF nut having lived and breathed xaml for over 2 years. [...]]]></description>
			<content:encoded><![CDATA[<p>Glenn Block has an excellent post titled “The spirit of MYYM, it’s not a code counting exercise”. The <a href="http://codebetter.com/blogs/glenn.block/archive/2009/08/02/the-spirit-of-mvvm-viewmodel-it-s-not-a-code-counting-exercise.aspx" onclick="urchinTracker('/outgoing/codebetter.com/blogs/glenn.block/archive/2009/08/02/the-spirit-of-mvvm-viewmodel-it-s-not-a-code-counting-exercise.aspx?referer=');">post</a> can be found at CodeBetter.</p>
<p>I thoroughly enjoyed the post and greatly appreciate practical discussions on WPF/SL application patterns. I am a bit of a WPF nut having lived and breathed xaml for over 2 years. I’ve been a part of 2 successful WPF projects (both in production). In both scenarios I acted as the defacto WPF guru. </p>
<p>This last project was a typical line of business application and we used the ViewModel pattern with Prism. I bring all this up to share my background with WPF and ViewModels.</p>
<p>Concerning the content of the post, I agree with Glenn on the majority of the content. The Commands and Parameters especially rings true. I found that whenever I went with option A [using element binding to a command parameter] I ended up refactoring it to option B [binding the ‘selected’ item to a property on the ViewModel]. Although a neat use of xaml, in practice the binding to the property just allowed more flexibility that indubitable becomes necessary with future changes and demands (not to mention testing opportunities).</p>
<p>With both projects we didn’t have the luxury of a full time designer. In both scenarios I argued there was plenty of work for a designer, but alas the resources just weren’t there. We were able to use a designer for a decent chunk of hours, but more could have been done. The applications were definitely better off for having every hour we could get from any designer resource. I believe the last project persuaded many that indeed there was enough work for a full time designer, so maybe I can hope for a designer with a future application.</p>
<p>I say this because I can not speak towards what its like having a designer in Blend all the time working on Views. When we used a designer resource, they would work in Blend and then a go-between developer / designer would take the xaml and integrate it with our ResourceDictionaries.</p>
<p>What I would like to address is the ‘no code behind’ philosophy compared to the code behind practicality.</p>
<p>Two years ago when I was floundering for WPF information and blogs, I ran across a blog post (I want to say it was Josh Smith) where the writer stated something like : “if something is easier to do in the code behind then its okay to do it in the code behind.”</p>
<p>He was arguing that a crap load of xaml vs a couple lines of code behind isn’t an argument at all. The code behind is the best choice. Naturally clearer intentions and code maintainability takes precedence over having a dogmatic “everything in xaml” approach. </p>
<p>With this last LoB Prism application, we had some choices to make when we were deciding on how the client should be made up.</p>
<p>Do we use UserControls as Views or (as Ryan Riley brought up) do we use Data Templates as views. I felt at the time the team wasn’t ready for that leap to Data Templates as views. I considered the code behind of a User Control as a placebo safety net for a team struggling with the WPF learning curve. What I did do was firmly encouraged a no code behind policy. A “no code behind” challenge if you will.</p>
<p>If I were to go back to the beginning and make that View decision again, I would go with the Data Templates as views. The team did very well without using the code behind. A Data Template view would have brought more benefits than the cost of having no code behind. Often we found ourselves thinking.. if this view was a data template and not a user control, then we could more easier do X.</p>
<p>I have championed the “no code behind” stance internal to Catapult and to other developers. Yes you can legitimately use the code behind to accomplish certain tasks. More often than not though (in my experience), the use of the code behind has more to do with the prejudices carried over from WinForms development. Having a strict no code behind stance forces developers to learn and change the way they think about coding functionality into the UI. </p>
<p>Glenn came up with a scenario (albiet a overly simplified one) of where he felt a code behind had some value. The scenario described is:</p>
<p>&#8216;”The user clicks a Save button on the Edit Order screen which requires some UI cue to the user such as an hourglass while the order is saving, and another cue once the Order has saved.”</p>
<p>He argues that the code in the xaml is less testable. He even suggests the solution I made. He also recognizes others my disagree. Count me in the disagreement camp.</p>
<p>I created a simple project that uses Attached Dependency properties to accomplish this simple scenario. This isn’t a “throw down the gauntlet” sort of thing and I didn’t really write it for Glenn. A coworker emailed Glenn’s blog and I responded in an email describing my solution. He then asked to see it in action. So I coded it up.</p>
<p>He also asked me to post a comment on Glenn’s post, but I don’t really see the point especially since I agree with the information Glenn is sharing and his opinions are built on experience &amp; expertise. I really had no disagreement and the solution Glenn already knows of. /shrug</p>
<p>Anyway.. you can find the solution here : <a title="http://github.com/RookieOne/AttachedAnimation/tree/master" href="http://github.com/RookieOne/AttachedAnimation/tree/master" onclick="urchinTracker('/outgoing/github.com/RookieOne/AttachedAnimation/tree/master?referer=');">http://github.com/RookieOne/AttachedAnimation/tree/master</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wizardsofsmart.net/patterns/mvvm-the-no-code-behind-challenge-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Problem with the MVC Frameworks &#8211; Introduction</title>
		<link>http://wizardsofsmart.net/patterns/the-problem-with-the-mvc-frameworks-introduction/</link>
		<comments>http://wizardsofsmart.net/patterns/the-problem-with-the-mvc-frameworks-introduction/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 18:03:50 +0000</pubDate>
		<dc:creator>panesofglass</dc:creator>
				<category><![CDATA[Patterns]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[Front Controller]]></category>
		<category><![CDATA[FubuMVC]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[OpenRasta]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://wizardsofsmart.net/uncategorized/the-problem-with-the-mvc-frameworks-introduction/</guid>
		<description><![CDATA[The anticipatory buzz about ASP.NET MVC last year has become a loud clanging about the general MVC pattern this year. We’ve got several people talking about the “M” in MVC (K. Scott, Rob &#38; Javier); the “right” way to make ASP.NET MVC work (Jimmy and Seb); and complete alternatives in the form of FubuMVC (Front [...]]]></description>
			<content:encoded><![CDATA[<p>The anticipatory buzz about ASP.NET MVC last year has become a loud clanging about the general MVC pattern this year. We’ve got several people talking about the “M” in MVC (<a href="http://odetocode.com/blogs/scott/archive/2009/03/30/12714.aspx" onclick="urchinTracker('/outgoing/odetocode.com/blogs/scott/archive/2009/03/30/12714.aspx?referer=');">K. Scott</a>, <a href="http://blog.wekeroad.com/subsonic/putting-the-ldquo-m-rdquo-back-in-mvc/" onclick="urchinTracker('/outgoing/blog.wekeroad.com/subsonic/putting-the-ldquo-m-rdquo-back-in-mvc/?referer=');">Rob</a> &amp; <a href="http://herdingcode.com/?p=177" onclick="urchinTracker('/outgoing/herdingcode.com/?p=177&amp;referer=');">Javier</a>); the “right” way to make ASP.NET MVC work (<a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/06/29/how-we-do-mvc-view-models.aspx" onclick="urchinTracker('/outgoing/www.lostechies.com/blogs/jimmy_bogard/archive/2009/06/29/how-we-do-mvc-view-models.aspx?referer=');">Jimmy</a> and <a href="http://serialseb.blogspot.com/2009/05/my-mvc-best-practices-talk.html" onclick="urchinTracker('/outgoing/serialseb.blogspot.com/2009/05/my-mvc-best-practices-talk.html?referer=');">Seb</a>); and complete alternatives in the form of <a href="http://fubumvc.pbworks.com/" onclick="urchinTracker('/outgoing/fubumvc.pbworks.com/?referer=');">FubuMVC</a> (<a href="http://www.lostechies.com/blogs/chad_myers/archive/2009/06/18/going-controller-less-in-mvc-the-way-fowler-meant-it.aspx" onclick="urchinTracker('/outgoing/www.lostechies.com/blogs/chad_myers/archive/2009/06/18/going-controller-less-in-mvc-the-way-fowler-meant-it.aspx?referer=');">Front Controller</a>), <a href="http://bistroframework.org/index.php?title=Bistro_Framework_Home" onclick="urchinTracker('/outgoing/bistroframework.org/index.php?title=Bistro_Framework_Home&amp;referer=');">Bistro</a> (Alex), and—related from a web development perspective if not MVC—<a href="http://openrasta.com/" onclick="urchinTracker('/outgoing/openrasta.com/?referer=');">OpenRasta</a> (<a href="http://serialseb.blogspot.com/" onclick="urchinTracker('/outgoing/serialseb.blogspot.com/?referer=');">Seb</a>). Why do we have all this complexity or all these options? I submit to you that the problems in the pattern as it relates to web design and the complex structures designed to handle it are a result of mixed metaphors; i.e., the web is not a UI but a service platform.</p>
<p>Before moving on, let me just say that by no means am I advocating WebForms or other, similar frameworks. Such things are atrocities that should never have been committed upon this earth. (Okay, I exaggerate a bit, but hopefully you get my point that while I’m about to rag on MVC, some of these other things are worse.)</p>
<p>As I wrote, this thing became far too long for a single post, so I’m breaking it up into sections. I also need to find and tie in the discussion I had with <a href="http://wizardsofsmart.net/author/rookieone">JB</a> about this very thing. I like how that discussion went, although it was based upon other discussions similar to those in the following posts:</p>
<p>1. <a href="http://wizardsofsmart.net/patterns/a-history-of-violence-against-html/">A History of Violence against HTML</a><br />
2. New Names for Old Things<br />
3. Serve me up some of that good ole Appl(ication)e Pie<br />
4. The Web is a Service Bus<br />
5. The Gauntlet</p>
<p>So stay tuned. There’s more to come. <img src='http://wizardsofsmart.net/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://wizardsofsmart.net/patterns/the-problem-with-the-mvc-frameworks-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Model Validation</title>
		<link>http://wizardsofsmart.net/patterns/model-validation/</link>
		<comments>http://wizardsofsmart.net/patterns/model-validation/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 04:03:59 +0000</pubDate>
		<dc:creator>panesofglass</dc:creator>
				<category><![CDATA[Patterns]]></category>
		<category><![CDATA[DomainModel]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://wizardsofsmart.net/patterns/model-validation/</guid>
		<description><![CDATA[I got into an interesting conversation with my friend and coworker David Morton regarding model validation. Where does it belong? I have seen examples of self-validating models, validation as a service, and even UI-only validation. Perhaps it depends on the implementation, but if you follow SOLID principles, I think you will at least end up [...]]]></description>
			<content:encoded><![CDATA[<p>I got into an interesting conversation with my friend and coworker <a title="David Morton's blog" href="http://blog.codinglight.com/" onclick="urchinTracker('/outgoing/blog.codinglight.com/?referer=');">David Morton</a> regarding model validation. Where does it belong? I have seen examples of self-validating models, validation as a service, and even UI-only validation.</p>
<p>Perhaps it depends on the implementation, but if you follow SOLID principles, I think you will at least end up with a validator type that performs the validation, either as a strategy on the model or a separate service.</p>
<p>We started with self-validating anemic domain models on my last project. That&#8217;s possibly an oversimplification, but it worked well for those models that were truly used in a CRUD-only manner. More complex models quickly became difficult to maintain, and as part of the refactoring, we split out the validation duties into their own class and now provide validation through the service layer for the client. This acts as a sort of anticorruption layer (Evans).</p>
<p>I really like this approach best. You can still call the validation from the client before sending, and your model may continue to focus on it&#8217;s real job. What are your thoughts or preferred approaches?</p>
]]></content:encoded>
			<wfw:commentRss>http://wizardsofsmart.net/patterns/model-validation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ViewModel Futures</title>
		<link>http://wizardsofsmart.net/patterns/viewmodel-futures/</link>
		<comments>http://wizardsofsmart.net/patterns/viewmodel-futures/#comments</comments>
		<pubDate>Wed, 13 May 2009 04:10:49 +0000</pubDate>
		<dc:creator>panesofglass</dc:creator>
				<category><![CDATA[Patterns]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[MVP]]></category>
		<category><![CDATA[MVVM]]></category>
		<category><![CDATA[ViewModel]]></category>

		<guid isPermaLink="false">http://wizardsofsmart.net/patterns/viewmodel-futures</guid>
		<description><![CDATA[Glenn Block asked two questions on Twitter tonight that were too good to pass up. First, do you want better tooling, more testable data binding, or a ViewModel base class? I agree with whoever said patterns exist to make up for faults in a language; however, in this case, I think I would choose enhancements [...]]]></description>
			<content:encoded><![CDATA[<p>Glenn Block asked two questions on Twitter tonight that were too good to pass up. First, do you want better tooling, more testable data binding, or a ViewModel base class? I agree with whoever said patterns exist to make up for faults in a language; however, in this case, I think I would choose enhancements to data binding. It&#8217;s a little too magical, imho.</p>
<p>I would like to see a ViewModel base eventually, though, as that would be one less thing to wire up myself, and it hopefully silence all the people complaining about the lack of a model in MVC. (Yes, I am thinking the backend models should be sharable among WPF, Silverlight, and MVC.)</p>
<p>Glenn&#8217;s second question related to tv target audience. I am always a fan of simple explocicity, to borrow a word from JB. I think that&#8217;s what the experts use. Also, I don&#8217;t know many who want to me mediocre some day, so going for the best and letting it trickle down is a great idea.</p>
<p>Just my $.02.</p>
]]></content:encoded>
			<wfw:commentRss>http://wizardsofsmart.net/patterns/viewmodel-futures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
