<?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>willcodeforcoffee.com &#187; Design Patterns</title>
	<atom:link href="http://willcodeforcoffee.com/category/design-patterns/feed/" rel="self" type="application/rss+xml" />
	<link>http://willcodeforcoffee.com</link>
	<description>The personal programming blog of Eric Hoff.</description>
	<lastBuildDate>Wed, 18 Jan 2012 20:03:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Bored Programmer Syndrome</title>
		<link>http://willcodeforcoffee.com/2011/06/02/bored-programmer-syndrome/</link>
		<comments>http://willcodeforcoffee.com/2011/06/02/bored-programmer-syndrome/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 00:17:36 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Humour]]></category>

		<guid isPermaLink="false">http://willcodeforcoffee.com/?p=181</guid>
		<description><![CDATA[Over-engineering, and under-designing a project is a common problem you will see when your programmer is bored. You'll see a bored programmer do things like over engineering with little design. <a href="http://willcodeforcoffee.com/2011/06/02/bored-programmer-syndrome/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When a programmer is bored he sometimes over-engineers and under-designs a project. We adopt an attitude like &#8220;well, if I have to do this in VS2005 and .NET 2.0 I may as well implement a service-locator and message bus and use all that technology I wanted to learn.</p>
<p><a href="http://en.wikipedia.org/wiki/Larry_Wall" _mce_href="http://en.wikipedia.org/wiki/Larry_Wall" target="_blank">Larry Wall</a> truthfully said the <a href="http://en.wikipedia.org/wiki/Larry_Wall#Virtues_of_a_programmer" _mce_href="http://en.wikipedia.org/wiki/Larry_Wall#Virtues_of_a_programmer">best virtues</a> for a programmer are <a href="http://c2.com/cgi/wiki?LazinessImpatienceHubris" _mce_href="http://c2.com/cgi/wiki?LazinessImpatienceHubris">laziness, impatience and hubris</a>. Sometimes you ignore these virtues when you get bored, you start to do stuff you know you shouldn&#8217;t, and your laziness doesn&#8217;t balance your hubris.</p>
<p>My new virtue that I&#8217;m going to work hard on is, ironically, laziness. <img src='http://willcodeforcoffee.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  KISS is the new methodology for me to follow: <span style="text-decoration: underline;" _mce_style="text-decoration: underline;">K</span>eep <span style="text-decoration: underline;" _mce_style="text-decoration: underline;">I</span>t <span style="text-decoration: underline;" _mce_style="text-decoration: underline;">S</span>imple, <span style="text-decoration: underline;" _mce_style="text-decoration: underline;">S</span>tupid for design, YAGNI: You Aren&#8217;t Gonna Need It for architecture.</p>
]]></content:encoded>
			<wfw:commentRss>http://willcodeforcoffee.com/2011/06/02/bored-programmer-syndrome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fluent Interface API Design</title>
		<link>http://willcodeforcoffee.com/2009/05/07/fluent-interface-api-design/</link>
		<comments>http://willcodeforcoffee.com/2009/05/07/fluent-interface-api-design/#comments</comments>
		<pubDate>Thu, 07 May 2009 03:28:17 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false">http://willcodeforcoffee.com/?p=82</guid>
		<description><![CDATA[I&#8217;m working at a new client and have written a few services to support a DotNetNuke CMS install, as well as a few modules.  To support the modules I&#8217;ve written one or two of my services using a Fluent Interface &#8230; <a href="http://willcodeforcoffee.com/2009/05/07/fluent-interface-api-design/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working at a new client and have written a few services to support a DotNetNuke CMS install, as well as a few modules.  To support the modules I&#8217;ve written one or two of my services using a <a href="http://martinfowler.com/bliki/FluentInterface.html" target="_blank">Fluent Interface</a> API.  This was fun and exciting, but some APIs didn&#8217;t make sense to be used fluently, or it complicated things more than I would have liked.</p>
<p>As a developer I think it is important to write the API so that it is usable and easy for a junior to understand.  Fluent is one way to do it, but it isn&#8217;t necessarily the only or best way!</p>
<p><span id="more-82"></span>Some places where I found Fluent difficult to use was if I needed to provide two parameters to an underlying service.  For instance its not uncommon in DotNetNuke to have to provide a User ID and a Module ID to one method call.  A Fluent Interface might say <code>DoSomething.ForUser(userId).WithModule(moduleId)</code>, but that means storing the userId.  And to prevent the user from doing <code>DoSomething.WithModule(moduleId).ForUser(userId)</code> you would have to do some tricks with interfaces, and that is just not fun or easy for another developer to understand or use!</p>
<p>Sometimes it makes more sense to <code>DoSomething.ApplyToSomthing(moduleId, userId)</code> &#8211; it just does.</p>
<p>Of course, there are always tricks like Func&lt;T&gt; out there that we can use.  Because Func&lt;T&gt; is a .NET Framework feature I would expect another developer to understand how to use it, maybe not a raw cadet just out of school, but the documentation is there on MSDN for us to learn from.  Still I would probably have to define a class and use a lamda expression to use the method.  Lambdas are awesome for condensing code into readable chunks, but <code>DoSomething.Using(p =&gt; { p.ModuleId = moduleId, p.UserId })</code> feels unwieldy to me.  It makes a lot more sense in FluentNHibernate than it does in a small API or wrapper because you&#8217;re creating configurations and large sets.</p>
<p>So I&#8217;m going to be careful with my API designs and continue to make them usable.  After all, the best developer is one who&#8217;s code is readable and usable when its done.  And the best code does what it is supposed to but is maintainable by a noob.</p>
]]></content:encoded>
			<wfw:commentRss>http://willcodeforcoffee.com/2009/05/07/fluent-interface-api-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Wrapup</title>
		<link>http://willcodeforcoffee.com/2009/03/16/project-wrapup/</link>
		<comments>http://willcodeforcoffee.com/2009/03/16/project-wrapup/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 17:17:53 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://willcodeforcoffee.com/?p=73</guid>
		<description><![CDATA[I just completed another project contract on Friday.  After decompressing over the weekend I wanted to write a few thoughts out about some of the successes and failures I&#8217;ve learned during this project. This project was a pretty good one. &#8230; <a href="http://willcodeforcoffee.com/2009/03/16/project-wrapup/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just completed another project contract on Friday.  After decompressing over the weekend I wanted to write a few thoughts out about some of the successes and failures I&#8217;ve learned during this project.</p>
<p><span id="more-73"></span>This project was a pretty good one.  Even though we put the application into production, the customer didn&#8217;t have enough money to keep me on long enough to finish the project in a state I would have been more happier with.  There were a few reasons for this I think: 1) the customer did not have a clear enough spec, in his mind, before I started, 2) the customer was too busy with other projects to give me enough attention and direction with the design, 3) the customer was too busy to help me get the application into a User Acceptance test site earlier than two days before the contract expired.  If we had a little more time, maybe one more month I think we could have turned the application into something excellent, and I could have seen it in use long enough to know if my design assumptions were good ones.</p>
<p>That said, I did spend a lot of time with one of the Users who was a database modelling expert.  I did learn a lot from him, and he really helped me understand more about what they were expecting as a customer.  Unfortunately he worked in another building, so access to him was severely limited too.</p>
<p>Another success was that this was my first ASP.NET MVC project to be deployed.  It was also my first use of NHibernate, which I also thought was very successful.  I also used jQuery and jQuery UI extensively for Web 2.0 stuff like dialogs (death to window.open!) and AJAX.  Those things were a lot of fun.</p>
<p>I also got to use a of new architectural planning and design (Domain Driven Design) pattern that I learned from a talk given by <a href="http://igloocoder.com/" target="_blank">Donald Belcham (aka The Igloo Coder)</a>.  I&#8217;ve been reading the <a href="http://www.amazon.ca/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215/" target="_blank">book by Eric Evans</a> as well.  This definitely seems like the new way to go.  DDD is about modelling your application and also about understanding the client&#8217;s needs.  I&#8217;m really impressed and eager to use it in future projects and products as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://willcodeforcoffee.com/2009/03/16/project-wrapup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NHibernate vs. SubSonic Another Look</title>
		<link>http://willcodeforcoffee.com/2009/01/22/nhibernate-vs-subsonic-another-look/</link>
		<comments>http://willcodeforcoffee.com/2009/01/22/nhibernate-vs-subsonic-another-look/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 21:26:05 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false">http://willcodeforcoffee.com/?p=68</guid>
		<description><![CDATA[Earlier I had compared NHibernate and SubSonic and chose SubSonic because it had migrations.  I&#8217;ve done two projects, one using SubSonic and the other using NHibernate and I can now compare the features a little better. NHibernate is documented better &#8230; <a href="http://willcodeforcoffee.com/2009/01/22/nhibernate-vs-subsonic-another-look/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Earlier I had compared NHibernate and SubSonic and chose SubSonic because it had migrations.  I&#8217;ve done two projects, one using SubSonic and the other using NHibernate and I can now compare the features a little better.</p>
<p>NHibernate is documented better than I originally thought if you look at nhforge.com, not at the hibernate site.  It also does some nice schema generation based on your mapping.  You still have to go through &#8220;XML Hell&#8221; to map the site, unless you use another mapper or FluentNHibernate (which does the mapping for you in code) or another tool.  As an ORM SubSonic feals cleaner and quicker since it generates the ORM classes from the database, where-as NHibernate generates the Schema from your mappings and ORM classes.</p>
<p><span id="more-68"></span></p>
<p>Generating the schema in NHibernate, even with Fluent-NHibernate, seems to take more work than generating the classes in SubSonic took.  However, it&#8217;s still quite simple.</p>
<p>Better support for Oracle was one of the primary drivers for me using NHibernate for this project, but after making the switch I&#8217;ve found a lot more interesting stuff, including an exciting ecosystem of NHibernate addins, plugins and updates.  I think it really appeals to the gadget geek in me.</p>
<p>The other thing that kept me thinking about NHibernate is the sheer number of other blogger / developers out there are using NHibernate!  After I started looking I was surprised to see how many blogging developers actually used NHibernate for their projects.  So not only do I feel like I&#8217;m in good company right now, but there are also a lot of people out there with good advice on best practices.</p>
<p>So, I&#8217;m taking another look at NHibernate right now, and I might post on it again later!</p>
]]></content:encoded>
			<wfw:commentRss>http://willcodeforcoffee.com/2009/01/22/nhibernate-vs-subsonic-another-look/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparing Open Source ORM: SubSonic vs. NHibernate</title>
		<link>http://willcodeforcoffee.com/2008/10/09/comparing-open-source-orm-subsonic-vs-nhibernate/</link>
		<comments>http://willcodeforcoffee.com/2008/10/09/comparing-open-source-orm-subsonic-vs-nhibernate/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 18:37:27 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false">http://willcodeforcoffee.com/?p=40</guid>
		<description><![CDATA[ORM tools are probably one of the most time-saving tools for a web developer.  Nothing is more tedious than building a data access layer, adding caching or coordinating transactions.  Well okay, sometimes things like that are really fun, but when &#8230; <a href="http://willcodeforcoffee.com/2008/10/09/comparing-open-source-orm-subsonic-vs-nhibernate/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>ORM tools are probably one of the most time-saving tools for a web developer.  Nothing is more tedious than building a data access layer, adding caching or coordinating transactions.  Well okay, sometimes things like that are really fun, but when you&#8217;re trying to start a project out from scratch you want to get something up and running ASAP to show to your customers.</p>
<p>In the .NET world there are two powerful ORM tools out there, <a title="http://www.hibernate.org/" href="http://www.hibernate.org/" target="_blank">NHibernate</a> and <a title="http://subsonicproject.com/" href="http://subsonicproject.com/" target="_blank">SubSonic</a>.  NHibernate is based on the successful and popular Java EE ORM Hibernate.  SubSonic is an entirely new ORM developed in the Ruby on Rails ActiveRecord development model, with some nice .NET 2.0 features like Controllers that you can use with ObjectDataSource controls.</p>
<p>For a recent project I quickly evaluated both software tools, and I&#8217;m publishing what I learned here.</p>
<p><span id="more-40"></span></p>
<p><strong>Setting up NHibernate:</strong></p>
<p>The NHibernate Object/Relational Mapping is setup using XML files.  If you&#8217;re using the 3.5 Framework you can use a fluent interface instead (i.e. code the mapping in C# instead of XML).  I didn&#8217;t find a tool that generated the XML or interface automatically for you, but there must be one out there.</p>
<p>Changes to the database require changing the mappings, which means digging through XML.</p>
<p><strong>Setting up SubSonic:</strong></p>
<p>SubSonic mappings are generated via an external tool called SubCommander run from the tools menu.  Any changes to the database require regenerating these mapped classes.  SubCommander connects to your database, reads the Schema and generates O/R classes.  The O/R classes are Partial classes in C# so that you can create methods for the classes that won&#8217;t get overwritten by the tool each time you write it.</p>
<p>Changes to the database require re-running SubCommander (which can be done via the IDE).</p>
<p>The SubSonic team has also come up with some great videos to help you get started.</p>
<p><strong>Migrations</strong></p>
<p>The big thing that sold me on SubSonic was the new <a href="http://subsonicproject.com/2-1-pakala/subsonic-using-migrations/" target="_blank">Migrations</a> feature.  It uses a Ruby on Rails style migrations tool to help keep your database versioned.  It&#8217;s really excellent for a first generation tool.  It&#8217;s missing a few things, like it&#8217;s hard to set Unique Keys, but otherwise it is excellent.  This is also the first .NET Migrations utility I&#8217;ve found.</p>
<p>Migrations are one of the easiest ways to keep your database versioned, which has always been a problem for me when updating Test and Production databases.</p>
<p><strong>Conclusion</strong></p>
<p>I ended up selecting SubSonic for the following reasons:</p>
<ol>
<li>No XML configuration files (running a tool is much easier, IMHO)</li>
<li>Migrations</li>
<li>Their excellent video tutorials and directions on their website</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://willcodeforcoffee.com/2008/10/09/comparing-open-source-orm-subsonic-vs-nhibernate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Open / Closed Principle</title>
		<link>http://willcodeforcoffee.com/2008/06/25/the-open-closed-principle/</link>
		<comments>http://willcodeforcoffee.com/2008/06/25/the-open-closed-principle/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 15:41:18 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false">http://willcodeforcoffee.com/2008/06/25/the-open-closed-principle/</guid>
		<description><![CDATA[I just read a great article in MSDN Magazine (available online here) on the Open / Closed Principle from the Patterns in Practice column.&#160; I really enjoyed it.&#160; I&#8217;m going to have to spend some more time learning some more &#8230; <a href="http://willcodeforcoffee.com/2008/06/25/the-open-closed-principle/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just read a great article in MSDN Magazine (available online <a href="http://msdn.microsoft.com/en-ca/magazine/cc546578.aspx" target="_blank">here</a>) on the Open / Closed Principle from the Patterns in Practice column.&#160; I really enjoyed it.&#160; I&#8217;m going to have to spend some more time learning some more design patterns.&#160; I&#8217;ve spent some time learning Model-View-Presenter (MVP) and Inversion of Control (IoC) but haven&#8217;t put either into practice yet.&#160; Who knows what the future holds though?</p>
]]></content:encoded>
			<wfw:commentRss>http://willcodeforcoffee.com/2008/06/25/the-open-closed-principle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

