<?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>Elegant Code</title>
	
	<link>http://elegantcode.com</link>
	<description />
	<lastBuildDate>Sat, 14 Nov 2009 00:17:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</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/ElegantCode" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>DTO’s, DDD &amp; The Anemic Domain Model</title>
		<link>http://elegantcode.com/2009/11/13/dtos-ddd-the-anemic-domain-model/</link>
		<comments>http://elegantcode.com/2009/11/13/dtos-ddd-the-anemic-domain-model/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 00:17:43 +0000</pubDate>
		<dc:creator>Jarod Ferguson</dc:creator>
				<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/13/dtos-ddd-the-anemic-domain-model/</guid>
		<description><![CDATA[I had a comment on my last post Tips for ORM Data Access which i would like like to address with this blog post.
I have been trying to wrap my head around the role of the DTO in DDD. My reading of Fowler and Evans seems to indicate that you ought to have your domain [...]]]></description>
			<content:encoded><![CDATA[<p>I had a comment on my last post <a href="http://elegantcode.com/2009/11/12/tips-for-orm-data-access/comment-page-1/#comment-50298">Tips for ORM Data Access</a> which i would like like to address with this blog post.</p>
<blockquote><p><em>I have been trying to wrap my head around the role of the DTO in DDD. My reading of Fowler and Evans seems to indicate that you ought to have your domain objects themselves mapping into your database, rather than dedicated function-less DTOs. Relying on DTOs that are then handled by Services seems to lead to what Fowler calls The Anemic Domain Anti-Pattern: </em><a href="http://martinfowler.com/bliki/AnemicDomainModel.html"><em>http://martinfowler.com/bliki/AnemicDomainModel.html</em></a></p>
<p><em>However, I have a tough time writing Entity classes that operate in that manner that don’t end up rather painful to change and extend.</em></p>
<p><em>Since you recommend the practice of using DTOs, do you have any thoughts on the subject?</em></p>
</blockquote>
<p>Thank you for the question Scott, of course I have thoughts on this <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong><em>Disclaimer: This sort of architecture is not applicable to many systems, use the right patterns and tools for the job! </em></strong></p>
<p>I agree that an anemic domain model is bad, if there is no behavior then what’s the point right? Let’s make sure I am on the same page here: </p>
<p>DTO: To me, a DTO moves data between ‘tiers’. They are the packaged data ready for transport. A WCF data contract is a perfect example of a DTO, I also see a JSON object as a DTO. </p>
<p>Read model: This would be a different model than your real Domain model.&#160; A Read model is very lightweight, ‘thin’ and anemic.&#160; Its purpose is to serve aggregated data to a specific screen or message. A DTO, to me, can be a read model, as too could be a View Model. </p>
<p>The domain model is rich and full of behavior. This model is most valuable when performing complex business rules during the saving and updating of data within a given transaction. It can also be used to read data too, but consider this contrived example: </p>
<p>Let’s say that we want to display the top 10 products. The products include the Manufacturer Name, Product Name, Vendor Name,&#160; Product Price,&#160; Customer Ranking. Being that we are good modelers we come up with something like the following entities: Vendor, Manufacturer, Product,&#160; &amp;&#160; ProductRanking (maybe localization &amp; currency support tables too).</p>
<p>If I use my domain model to get this data, I am going to end up retrieving quite a bit more data than I actually need, which could degrade performance. Not to mention having to deal with dot notation everywhere foo.Name =a.b.c.d.&#160; </p>
<p>We only need 5 fields, and they are immutable for this operation. </p>
<p>My preference is to materialize the read model (DTO, View Model) by projecting from the Domain Model, or by using a Stored Procedure for more complicated recursive, spatial or temporal queries. </p>
<p>Splitting the models allows the reads &amp; writes to fluctuate independently, so which leads to higher maintainability. These models can also run on different tiers/nodes to increase scalability (read/cache tier, write tier). </p>
<p>At some point, whether off a view or an inbound DTO, there will be mapping back into the domain model. This ‘friction’ or ‘impedance’ is pretty easy to manage using an assembler/translator, or a tool like AutoMapper. </p>
<p>Greg Young &amp; Udi Dahan take this concept further and apply a programming principle called Command-Query Separation with distributed programming and SOA. I think it is very good stuff. </p>
<p>Here are some posts that are all somewhat related:   <br /><a href="http://jonathan-oliver.blogspot.com/2009/03/dddd-and-cqs-getting-started.html">http://jonathan-oliver.blogspot.com/2009/03/dddd-and-cqs-getting-started.html</a>    <br /><a href="http://www.udidahan.com/2008/08/11/command-query-separation-and-soa/">http://www.udidahan.com/2008/08/11/command-query-separation-and-soa/</a>    <br /><a href="http://codebetter.com/blogs/gregyoung/archive/2009/08/13/command-query-separation.aspx">http://codebetter.com/blogs/gregyoung/archive/2009/08/13/command-query-separation.aspx</a>    <br /><a href="http://elegantcode.com/2008/04/27/dtos-or-serialized-domain-entities/">http://elegantcode.com/2008/04/27/dtos-or-serialized-domain-entities/</a>    <br /><a href="http://elegantcode.com/2008/04/30/altnet-seattle-takeawayddddresources/">http://elegantcode.com/2008/04/30/altnet-seattle-takeawayddddresources/</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=7epxTKR0Wek:bModkqeddEM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=7epxTKR0Wek:bModkqeddEM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=7epxTKR0Wek:bModkqeddEM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=7epxTKR0Wek:bModkqeddEM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=7epxTKR0Wek:bModkqeddEM:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=7epxTKR0Wek:bModkqeddEM:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/7epxTKR0Wek" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/13/dtos-ddd-the-anemic-domain-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the jQuery UI Datepicker with ASP.NET MVC 2 Templates</title>
		<link>http://elegantcode.com/2009/11/13/using-the-jquery-ui-datepicker-with-asp-net-mvc-2-templates/</link>
		<comments>http://elegantcode.com/2009/11/13/using-the-jquery-ui-datepicker-with-asp-net-mvc-2-templates/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 16:25:10 +0000</pubDate>
		<dc:creator>Jason Grundy</dc:creator>
				<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/13/using-the-jquery-ui-datepicker-with-asp-net-mvc-2-templates/</guid>
		<description><![CDATA[Brad Wilson has recently completed a blog series about Templates in MVC 2. I really like this feature as it provides me with the ability to quickly generate screens, even if eventually I might have to go back and rework them. Basically I want to have my cake and eat it – I want the [...]]]></description>
			<content:encoded><![CDATA[<p>Brad Wilson has recently completed a blog series about <a href="http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-1-introduction.html">Templates in MVC 2</a>. I really like this feature as it provides me with the ability to quickly generate screens, even if eventually I might have to go back and rework them. Basically I want to have my cake and eat it – I want the initial productivity of a scaffolding based approach but the flexibility to customize look and feel when required.</p>
<p>By default an text box is generated for DateTime fields. What I wanted to do was hook this up to the excellent Datepicker widget from <a href="http://jqueryui.com/demos/datepicker/">jQuery UI</a>. Here’s how I achieved this:</p>
<ol>
<li>Add the following 3 references to the Master Page:     </p>
<p>&lt;script type=&quot;text/javascript&quot; src=&quot;<a href="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;">http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;</a>&gt;&lt;/script&gt;      <br />&lt;script type=&quot;text/javascript&quot; src=&quot;<a href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js&quot;">http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js&quot;</a>&gt;&lt;/script&gt;      <br />&lt;link href=&quot;<a href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/overcast/jquery-ui.css&quot;">http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/overcast/jquery-ui.css&quot;</a> type=&quot;text/css&quot; rel=&quot;Stylesheet&quot; class=&quot;ui-theme&quot; /&gt;      </p>
<p>I am referencing jQUery and jQUery UI from the Google CDN (great for getting started quickly as well as for production scenarios). I am also linking to one of the <a href="http://jqueryui.com/themeroller/">default themes</a> which goes nicely with the default MVC stylesheet.      </li>
<li>Add the following Javascript to the Master Page:
<p>&lt;script type=&quot;text/javascript&quot;&gt;      <br />&#160;&#160;&#160; $(function () {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $(&quot;.date-edit-box&quot;).datepicker();      <br />&#160;&#160;&#160; });      <br />&lt;/script&gt;       </p>
<p>Here I am simply looking for a specific class and attaching a Datepicker widget to it. I am aware that this is not the most efficient approach as the code might run unnecessarily but it’s perfect for a demo.      </li>
<li>Ensure that the correct class is rendered by the Template. Apparently you can currently only override the default templates for individual Controllers. Therefore create a Views/{ControllerName}/EditorTemplates folder and within it create a file called DateTime.ascx which should contain:</li>
<p>&lt;%@ Control Language=&quot;C#&quot; Inherits=&quot;System.Web.Mvc.ViewUserControl&quot; %&gt; </p>
<p>&lt;%= Html.TextBox(&quot;&quot;, ViewData.TemplateInfo.FormattedModelValue, new { @class = &quot;date-edit-box&quot; }) %&gt;</p>
<li>You’ll probably want to use the DIsplayFormatAttribute on the DateTime fields in the View Model to ensure that the time is not also output (don’t forget to set the ApplyFormatInEditMode property to true if you do this).</li>
</ol>
<p>That’s it. You should now see Datepickers for the appropriate fields that were rendered using the Html.EditorForModel() extension method.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=tT_L2HveMZw:kMn5pb_ZwqM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=tT_L2HveMZw:kMn5pb_ZwqM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=tT_L2HveMZw:kMn5pb_ZwqM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=tT_L2HveMZw:kMn5pb_ZwqM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=tT_L2HveMZw:kMn5pb_ZwqM:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=tT_L2HveMZw:kMn5pb_ZwqM:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/tT_L2HveMZw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/13/using-the-jquery-ui-datepicker-with-asp-net-mvc-2-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tips for ORM Data Access</title>
		<link>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/</link>
		<comments>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 22:32:24 +0000</pubDate>
		<dc:creator>Jarod Ferguson</dc:creator>
				<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/12/tips-for-orm-data-access/</guid>
		<description><![CDATA[In my last post I took a stab at Lazy Loading data access, and pointed out a concrete example of why I don’t like it. As with anything there are trade-offs. Here are a few practices I use for clean and fast data access. They are heavily influenced by some common patterns from PoEAA, and [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://elegantcode.com/2009/11/12/lazy-loading-is-well-lazy/">last post I took a stab at Lazy Loading data access</a>, and pointed out a concrete example of why I don’t like it. As with anything there are trade-offs. Here are a few practices I use for clean and fast data access. They are heavily influenced by some common patterns from <a href="http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420">PoEAA</a>, and <a href="http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1258062865&amp;sr=1-1">Domain Driven Design</a>. </p>
<ul>
<li>Retrieve data by <a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/05/20/entities-value-objects-aggregates-and-roots.aspx">aggregate roots</a>, have a <a href="http://martinfowler.com/eaaCatalog/repository.html">repository</a> for each root. The root queries should return the entire aggregate. If you are going to defer loading to a part of the root graph, be explicit. Instead of lazy loading Foo.Bars, I like to say Foo.LoadBars() &lt;- yes seriously</li>
<li>Learn how to <a href="http://www.udidahan.com/2009/01/24/ddd-many-to-many-object-relational-mapping/">identify the right aggregate</a> </li>
<li>Respect your aggregate root boundaries. Aggregates cannot call into other aggregates children! You shouldn’t be adding a product from the order, really, this is bad: LineItem.Product.Calatalog.Add(new Product). The order AR just crossed into the Catalog AR. Its not the job of the Order to add products to the catalog</li>
<li>Do not try an overuse an aggregate, its ok to create a new one. Less is more does not apply. Fulfilling an order is different than placing one, and your data access may need to reflect that</li>
<li>Use a ‘Read Model’. The most common approach here is using <a href="http://martinfowler.com/eaaCatalog/dataTransferObject.html">DTO</a> or <a href="http://geekswithblogs.net/michelotti/archive/2009/10/25/asp.net-mvc-view-model-patterns.aspx">ViewModel</a>, and <a href="http://cetinbasoz.spaces.live.com/Blog/cns!D13F81744709AB9F!209.entry?sa=914843388">projecting</a> straight into it from the object model query or database </li>
<li>For complex queries that perform aggregations and calculations, consider using a store procedure. They really have their place, even with the best ORM’s (then project into Read Model)</li>
<li>Avoid putting query logic in mappings (<a href="http://martinfowler.com/eaaCatalog/dataTransferObject.html">Assembler’s</a>, Translators, <a href="http://www.codeplex.com/AutoMapper">AutoMapper</a>) </li>
<li>Use a tracing tool. I like the <a href="http://www.developer.com/db/article.php/3482216/Introduction-to-SQL-Profiler.htm">SQL trace profiler</a>, but if you are not as comfortable with sql, there is a some good profilers around, like <a href="http://www.nhprof.com/">NHProf</a> for nHiberante &amp; soon <a href="http://ayende.com/Blog/archive/2009/11/06/entity-framework-profiler.aspx">EFProf</a> for the Entity Framework </li>
<li>Know the SQL that is going to your database. Have your <a href="http://blogs.microsoft.co.il/blogs/gilf/archive/2009/02/06/totracestring-method-in-entity-framework.aspx">tests emit the generated sql out to the console</a>. Live it, learn it, love it. You should know your ORM tendencies, especially if you are using a linq provider </li>
<li>Batch requests to your <a href="http://davybrion.com/blog/2008/06/batching-wcf-calls/">services</a> and <a href="http://davybrion.com/blog/2009/04/transparent-query-batching-through-your-repository/">database</a>, especially if you are in a web or distributed environment</li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=jDjcfKnkZzo:8qhEd-4INgg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=jDjcfKnkZzo:8qhEd-4INgg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=jDjcfKnkZzo:8qhEd-4INgg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=jDjcfKnkZzo:8qhEd-4INgg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=jDjcfKnkZzo:8qhEd-4INgg:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=jDjcfKnkZzo:8qhEd-4INgg:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/jDjcfKnkZzo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/12/tips-for-orm-data-access/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Lazy Loading is… well… lazy</title>
		<link>http://elegantcode.com/2009/11/12/lazy-loading-is-well-lazy/</link>
		<comments>http://elegantcode.com/2009/11/12/lazy-loading-is-well-lazy/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 22:31:13 +0000</pubDate>
		<dc:creator>Jarod Ferguson</dc:creator>
				<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/12/lazy-loading-is-well-lazy/</guid>
		<description><![CDATA[I find it ironic that we allow our tooling to mask the biggest bottleneck in the system: The database. Having worked with the majority of the ORM tools out there, I can tell you the most common contributor to slow system performance is lazy loading for Data Access. 
I’ve seen this one all too many [...]]]></description>
			<content:encoded><![CDATA[<p><strong>I find it ironic that we allow our tooling to mask the biggest bottleneck in the system: The database.</strong> Having worked with the majority of the ORM tools out there, I can tell you <strong>the most common contributor to slow system performance is <a href="http://en.wikipedia.org/wiki/Lazy_loading">lazy loading</a> for Data Access.</strong> </p>
<p>I’ve seen this one all too many times:</p>
<blockquote><p><strong>Business guy:</strong> The order checkout screen is running slow in production</p>
<p><strong>Dev:</strong> It shouldn’t be, it runs great on my machine</p>
<p><strong>Business guy:</strong> Well, it is. It takes 10-15 seconds to load order 123</p>
<p><strong>Dev:</strong> Let me check, ya hmm, it is slow. I’ll look into it</p>
</blockquote>
<p>The developer proceeds to crack open the source where he finds some <a href="http://en.wikipedia.org/wiki/Law_of_Demeter">LOD</a> nightmare data binding mess in the view, or the mapping to the <a href="http://martinfowler.com/eaaDev/PresentationModel.html">presentation model</a>: “Customer.Order-&gt; LineItem.Product.Catalog.Vendor.Name”</p>
<p>Because someone wanted to display the Vendor name on the line detail, they just hopped over the graph and loaded the catalog, and then vendor. So here comes the entire catalog! (of course its <a href="http://ayende.com/Blog/archive/2006/05/02/CombatingTheSelectN1ProblemInNHibernate.aspx">N + 1</a>) </p>
<p><strong>Why did they do that? Because it is EASY</strong>! (and because your boss wanted it yesterday)</p>
<p>The team never knows about it until it’s too late. Yep, it runs fast locally, because we developers only have a small catalog on our machine, I mean “we don’t want all that data on our box”.</p>
<p>Now I know there are many folks out there saying “Well that’s just stupid, I would never do that”. Maybe you wouldn’t, but that guy sitting next to you, he will. I tell you, we all do it, again and again.</p>
<p><strong>The result over time is an interconnected web of queries that can bring a system to a crawl</strong>.</p>
<p><a href="http://elegantcode.com/2009/11/12/tips-for-orm-data-access/">See my follow up post</a> for some tips I use when designing a data access layer with an ORM</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=VOAl6DUBTIQ:v8coLFeeT34:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=VOAl6DUBTIQ:v8coLFeeT34:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=VOAl6DUBTIQ:v8coLFeeT34:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=VOAl6DUBTIQ:v8coLFeeT34:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=VOAl6DUBTIQ:v8coLFeeT34:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=VOAl6DUBTIQ:v8coLFeeT34:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/VOAl6DUBTIQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/12/lazy-loading-is-well-lazy/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>NHibernate 3.0 QueryOver</title>
		<link>http://elegantcode.com/2009/11/12/nhibernate-3-0-queryover/</link>
		<comments>http://elegantcode.com/2009/11/12/nhibernate-3-0-queryover/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 19:23:53 +0000</pubDate>
		<dc:creator>Jason Grundy</dc:creator>
				<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/12/nhibernate-3-0-queryover/</guid>
		<description><![CDATA[One of the personal reasons that I had for co-founding Guild 3 was for me to re-discover my passion for software. I was suffering from something similar to what Davy Brion (quite bravely) outlined in Avoiding (Or Recovering From) Burnout. For me the age old adage of “a change is as good as a rest” [...]]]></description>
			<content:encoded><![CDATA[<p>One of the personal reasons that I had for co-founding <a href="http://guild3.com">Guild 3</a> was for me to re-discover my passion for software. I was suffering from something similar to what Davy Brion (quite bravely) outlined in <a href="http://davybrion.com/blog/2009/09/avoiding-or-recovering-from-burnout/">Avoiding (Or Recovering From) Burnout</a>. For me the age old adage of “a change is as good as a rest” has proven to be an extremely successful strategy.</p>
<p>One of the things that I had stopped doing was keeping an eye on various OSS projects to see what was on the horizon. Yesterday I (finally!) started to experiment with NHibernate 3.0. The first thing that caught my eye was <a href="http://fabiomaulo.blogspot.com/2009/06/criteria-on-nh300.html">QueryOver</a>. As Fabio explained there are a <a href="http://fabiomaulo.blogspot.com/2009/09/nhibernate-queries.html">lot of different ways of executing queries in NH</a>. Certainly in the pre-LINQ days ICriteria was the predominantly recommended option because it has elements of type safety to it and its fluent-ish API broke everything down into small pieces and avoided string concatenation hell.</p>
<p>QueryOver is fluent a layer on top of ICriteria. It looks very LINQesque but it’s a very different animal, not least of all because there are some concepts in ICriteria that do not have a LINQ equivalent (caching etc.). In the short to medium term I suspect that it will become my de facto approach for NHibernate queries (I’ve used NHibernate LINQ and it’s great for simple queries but I’ve experienced significant issues with more complicated ones).</p>
<p>What I haven’t figured out yet is how, if at all, this will affect my data access testing strategy. Historically I’ve favored smoke tests that have really been doing little more than verifying that a given ICriteria query was semantically valid. Typically I only resorted to actually worrying about the results in specific cases (mainly due to the burden of maintaining test data for each possible scenario). Then again this sounds like a topic for another post doesn’t it…</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=UJohPj6xrJ0:0yWLK53sFLM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=UJohPj6xrJ0:0yWLK53sFLM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=UJohPj6xrJ0:0yWLK53sFLM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=UJohPj6xrJ0:0yWLK53sFLM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=UJohPj6xrJ0:0yWLK53sFLM:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=UJohPj6xrJ0:0yWLK53sFLM:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/UJohPj6xrJ0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/12/nhibernate-3-0-queryover/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Delete a work Item in TFS</title>
		<link>http://elegantcode.com/2009/11/11/delete-a-work-item-in-tfs/</link>
		<comments>http://elegantcode.com/2009/11/11/delete-a-work-item-in-tfs/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 21:44:38 +0000</pubDate>
		<dc:creator>Kirstin Juhl</dc:creator>
				<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/11/delete-a-work-item-in-tfs/</guid>
		<description><![CDATA[I needed to delete a work item in TFS and found that by design it is not easy to do.
I found that this can be done using the TFS Power Tools via the command line.
tfpt.exe destroywi /server:http://ServerName:8080 /workitemid:123
You will get a warning:
This action is not recoverable. Are you sure you want to destroy work item(s)123? [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to delete a work item in TFS and found that by design it is not easy to do.</p>
<p>I found that this can be done using the TFS Power Tools via the command line.</p>
<p>tfpt.exe destroywi /server:http://ServerName:8080 /workitemid:123</p>
<p>You will get a warning:</p>
<p>This action is not recoverable. Are you sure you want to destroy work item(s)123? (Y/N)</p>
<p>Work item is gone.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=isWtgq_KRP4:apO9OWEFS_w:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=isWtgq_KRP4:apO9OWEFS_w:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=isWtgq_KRP4:apO9OWEFS_w:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=isWtgq_KRP4:apO9OWEFS_w:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=isWtgq_KRP4:apO9OWEFS_w:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=isWtgq_KRP4:apO9OWEFS_w:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/isWtgq_KRP4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/11/delete-a-work-item-in-tfs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slides from ALPN Meeting</title>
		<link>http://elegantcode.com/2009/11/11/slides-from-alpn-meeting/</link>
		<comments>http://elegantcode.com/2009/11/11/slides-from-alpn-meeting/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 14:57:25 +0000</pubDate>
		<dc:creator>Scott Schimanski</dc:creator>
				<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/11/slides-from-alpn-meeting/</guid>
		<description><![CDATA[On October 29th, I participated in the first ALPN workshop.&#160; I presented on general engineering principles for agile development and had a great time doing it.&#160; There was lots of wonderful group participation and input.&#160; Here are the slides: ALPN_AgileEngineering.pdf
Jason Dean and the ALPN group is leading a series of workshops on Agile practices.&#160; They [...]]]></description>
			<content:encoded><![CDATA[<p>On October 29th, I participated in the first ALPN workshop.&#160; I presented on general engineering principles for agile development and had a great time doing it.&#160; There was lots of wonderful group participation and input.&#160; Here are the slides: <a href="http://elegantcode.com/wp-content/uploads/2009/11/ALPN_AgileEngineering.pdf">ALPN_AgileEngineering.pdf</a></p>
<p>Jason Dean and the ALPN group is leading a series of workshops on Agile practices.&#160; They are designed to proceed from entry level discussions to more advanced.&#160; Look for more information on further workshops.</p>
<p>&#160;</p>
<p>For more information, checkout:</p>
<p>The website: <a href="http://www.agileboise.org">www.agileboise.org</a></p>
<p>The ALPN Boise Google group: <a href="http://groups.google.com/group/apln-boise?hl=en&amp;pli=1">http://groups.google.com/group/apln-boise?hl=en&amp;pli=1</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=BifbMr1WN2o:nS9s2jSmv94:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=BifbMr1WN2o:nS9s2jSmv94:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=BifbMr1WN2o:nS9s2jSmv94:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=BifbMr1WN2o:nS9s2jSmv94:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=BifbMr1WN2o:nS9s2jSmv94:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=BifbMr1WN2o:nS9s2jSmv94:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/BifbMr1WN2o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/11/slides-from-alpn-meeting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unrecognized attribute ‘targetFramework’ – Asp.Net 4.0</title>
		<link>http://elegantcode.com/2009/11/10/unrecognized-attribute-targetframework-asp-net-4-0/</link>
		<comments>http://elegantcode.com/2009/11/10/unrecognized-attribute-targetframework-asp-net-4-0/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 22:20:30 +0000</pubDate>
		<dc:creator>Jarod Ferguson</dc:creator>
				<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/10/unrecognized-attribute-targetframework-asp-net-4-0/</guid>
		<description><![CDATA[I ran across this error after pushing out an upgraded .NET 4.0 MVC2 application to its existing IIS website.&#160; After some digging around I found this document on MSDN: How to: Upgrade an ASP.NET Web Application to ASP.NET 4
Since the application was previously built on version 3.5, IIS was configured to run as Asp.Net 2.0. [...]]]></description>
			<content:encoded><![CDATA[<p>I ran across this error after pushing out an upgraded .NET 4.0 MVC2 application to its existing IIS website.&#160; After some digging around I found this document on MSDN: <a href="http://msdn.microsoft.com/en-us/library/dd483478%28VS.100%29.aspx">How to: Upgrade an ASP.NET Web Application to ASP.NET 4</a></p>
<p>Since the application was previously built on version 3.5, IIS was configured to run as Asp.Net 2.0. Well it turns out IIS runs under the new framework version 4.0. (not like 3.0, or 3.5 when the Application Pool runs as 2.0) </p>
<p>Kind of one those &quot;I should have figured that out much quicker moments&quot;&#8230; A simple change to the app pool to target 4.0, and were on our way. </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=rJ02m5p92X8:0fXOo3Qt4RI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=rJ02m5p92X8:0fXOo3Qt4RI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=rJ02m5p92X8:0fXOo3Qt4RI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=rJ02m5p92X8:0fXOo3Qt4RI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=rJ02m5p92X8:0fXOo3Qt4RI:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=rJ02m5p92X8:0fXOo3Qt4RI:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/rJ02m5p92X8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/10/unrecognized-attribute-targetframework-asp-net-4-0/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>StructureMap and SharePoint</title>
		<link>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</link>
		<comments>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:22 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</guid>
		<description><![CDATA[I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; 
I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; </p>
<p>I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user is authorized to use.&#160; The source of this data (names, URLs, etc.) comes from an external-to-SharePoint system, accessed through another C# assembly.&#160; Once the web part gets the data there is some more processing to be done – we need to do more than just blindly display a list of URLs.&#160; Rather than get into details I’m just going to do some handwaving here and say that “if you have access to X, then {stuff happens}, or if you have access to Y then {other stuff happens}.”&#160; You know, business logic, stuff that is good to test.</p>
<p>the first thing I need to do is get business logic out of the WebPart and into something that I can write without having to reset AppPools over and over, not to mention have some unit tests to verify I’m going in the right direction.&#160; So, I created a standard application service class which has a dependency on the external authorization system, via constructor injection.&#160; </p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> AuthorizedAppsService : IAuthorizedAppsService
{
  <span class="kwrd">private</span> <span class="kwrd">readonly</span> ExternalAuthorizeService authService;

  <span class="kwrd">public</span> AuthorizedAppsService(
    ExternalAuthorizeService authService)
  {
    <span class="kwrd">this</span>.authService = authService;
  }

  <span class="kwrd">public</span> AuthorizedApplications GetAuthorizedApplications(
                                  <span class="kwrd">string</span> userName)
  {
    var allApps = authService.AuthorizedApplications(userName);
    <span class="rem">// business logic stuff happens here</span>
    <span class="kwrd">return</span> thoseResultsWeJustFiguredOut;
  }
}</pre>
<p>Next, I created a StructureMap Registry class to scan my assemblies, as well as adding in the details of how to create this external authorize service, using the typical method:<br />
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: x-small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyRegistry : Registry
{
  <span class="kwrd">public</span> MyRegistry()
  {
    Scan(scanner =&gt; {
      scanner.TheCallingAssembly();
      scanner.AssemblyContainingType(<span class="kwrd">typeof</span>(MyRegistry));
      scanner.WithDefaultConventions();
      });

    ForRequestedType&lt;ExternalAuthorizeService&gt;()
      .AsSingletons()
      .TheDefault.Is.ConstructedBy(c =&gt; Provider.GetService());

    <span class="rem">// other dependency configuration...</span>
  }
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeForSharepoint()
  {
    ObjectFactory.Initialize(init =&gt; init.AddRegistry&lt;MyRegistry&gt;());
    ObjectFactory.AssertConfigurationIsValid();
  }
}</pre>
<p>And then, what remains is to have SharePoint call my StructureMap initialization when my SharePoint application starts up.&#160; In an MVC or WebForms app, I’d just add code to the appropriate place in Global.asax.cs, but in SharePointLand, this is looked down on.&#160; Instead, the preferred mechanism seems to be to use an HttpModule and a FeatureReceiver to plug the Module into the app’s web.config.</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyStartupModule : IHttpModule
{
  <span class="kwrd">public</span> <span class="kwrd">void</span> Init(HttpApplication context)
  {
        ConfigureOtherStuff();
        MyRegistry.InitializeForSharepoint();
  }
  <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose() { }
}</pre>
<p>And then the FeatureReceiver to alter the app’s Web.Config looks something like this (note I borrowed most of this code from another sample SharePoint project:</p>
<p>&#160;</p>
<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// this is borrowing heavily from http://www.codeplex.com/SPAXO</span>
<span class="rem">// </span>
<span class="kwrd">public</span> <span class="kwrd">class</span> StartupFeatureReceiver : SPFeatureReceiver
{
  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureActivated(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    AddWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureDeactivating(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    RemoveWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> AddWebConfigEntry(SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    var existingModifications =
             <span class="kwrd">new</span> List&lt;SPWebConfigModification&gt;(
                      webApp.WebConfigModifications);
    <span class="kwrd">if</span> (existingModifications.FindIndex(
                    <span class="kwrd">value</span> =&gt;
                        <span class="kwrd">value</span>.Name == mod.Name &amp;&amp;
                        <span class="kwrd">value</span>.Value == mod.Value &amp;&amp;
                        <span class="kwrd">value</span>.Owner == mod.Owner) == -1)
    {
      <span class="rem">// If the modifcation does not already exist </span>
      <span class="rem">// add the entry to the config</span>
      webApp.WebConfigModifications.Add(mod);
    }
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveWebConfigEntry(
            SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    webApp.WebConfigModifications.Remove(mod);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> SPWebConfigModification GetModification()
  {
    <span class="kwrd">string</span> asmName = <span class="kwrd">typeof</span>(StartupModule).AssemblyQualifiedName;
    <span class="kwrd">string</span> typeName = <span class="kwrd">typeof</span>(StartupModule).FullName;

    <span class="kwrd">return</span> <span class="kwrd">new</span> SPWebConfigModification
      {
        Path = <span class="str">&quot;configuration/system.web/httpModules&quot;</span>,
        Name = String.Format(CultureInfo.InvariantCulture,
                <span class="str">&quot;add[@name='{0}'][@type='{1}']&quot;</span>,
                typeName, asmName),
        Sequence = 0,
        Owner = asmName,
        Type = SPWebConfigModification.
                    SPWebConfigModificationType.EnsureChildNode,
        Value = String.Format(CultureInfo.InvariantCulture,
                  <span class="str">&quot;&lt;add name='{0}' type='{1}' /&gt;&quot;</span>,
                  typeName, asmName)
      };
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> UpdateApp(SPWebApplication webApp)
  {
    <span class="rem">// Update the Web App and apply the changes </span>
    <span class="rem">// to all servers in the farm</span>
    webApp.Update();
    webApp.Farm.Services
        .GetValue&lt;SPWebService&gt;()
        .ApplyWebConfigModifications();
  }
}</pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=Qi7cda5QT2I:XwO2qnD-SU8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=Qi7cda5QT2I:XwO2qnD-SU8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=Qi7cda5QT2I:XwO2qnD-SU8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=Qi7cda5QT2I:XwO2qnD-SU8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=Qi7cda5QT2I:XwO2qnD-SU8:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=Qi7cda5QT2I:XwO2qnD-SU8:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/Qi7cda5QT2I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Why my Mom and Ted Neward Irritate Me</title>
		<link>http://elegantcode.com/2009/11/09/why-my-mom-and-ted-neward-irritate-me/</link>
		<comments>http://elegantcode.com/2009/11/09/why-my-mom-and-ted-neward-irritate-me/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 06:56:31 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Agile]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/why-my-mom-and-ted-neward-irritate-me/</guid>
		<description><![CDATA[My mother is a psychologist and recently visited me us here in Idaho. We spent some time talking about the psychology behind some agile practices. Pretty cool!
Additionally, we ended up on the one mystery topic that has always eaten away at me. That mystery for me is simple:
Why does one person or team pursue excellence [...]]]></description>
			<content:encoded><![CDATA[<p>My mother is a psychologist and recently visited me us here in Idaho. We spent some time talking about the psychology behind some agile practices. Pretty cool!</p>
<p>Additionally, we ended up on the one mystery topic that has always eaten away at me. That mystery for me is simple:</p>
<blockquote><p>Why does one person or team pursue excellence relentlessly while another hits the door at 5:01 and doesn’t think about software development until tomorrow morning?</p>
</blockquote>
<p>I got into the same discussion with <a href="http://blogs.tedneward.com/" target="_blank">Ted Neward</a> at the recent P&amp;P Summit while playing pool. Heck, it was almost an argument. <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I said something stupid that night. I said, “It’s all about incentives.”</p>
<p>Wrong.</p>
<h2>One Theory: Incentives</h2>
<p>I have had the opinion for years that there must be some motivator, some technique, or some dynamic that will affect people positively to simply care. This is the whole idea behind coaching, after all. A well-versed and motivating individual comes into a team and works with them to get better results. This happens every day.</p>
<p>If this will really work, it necessarily means that people are motivated by incentive. What I mean by that conditions like salary, a great leader, wonderful co-workers, free pizza and soda (or something) will inherently motivate someone to care about excellence. </p>
<p>Certainly no one can deny that incentives like these contribute to an enjoyable workplace. Heck, I love visiting the Microsoft campus and downing those free V-8s. All of them combined though, probably cannot cause someone to ponder, read, and learn. Incentives cannot move someone to try a new coding technique just because it might be interesting.</p>
<h2>The Irritatingly Simpler Theory that is Likely True</h2>
<p>There is just something about unique about people who can’t stop trying to improve. It isn’t the great boss or the great office space that causes me to think about the finer points of TDD in the shower. It’s just because I can’t NOT do it.</p>
<p>Both my mom and Ted Neward tried to get me to see that incentives will get you behavior and results (sometimes the ones you actually want), but can’t create passion. That is something that is simply innately there or not there.</p>
<p>This isn’t to say that there is no value in the person who wants to do their bid and get fair pay for a fair day. That’s not what I’m talking about. I am talking about the fact that most genius is recognized by relentless pursuit, the kind we can’t define.</p>
<h2>The Good News</h2>
<p>OK. Uncle, I get it. The great news is there are so many of us passionate geeks out there striving to improve. You wouldn’t likely be reading this if you weren’t one. Heck, I even geek <a href="http://guild3.com" target="_blank">to work with some</a>!</p>
<p>What’s your theory? Are passionate professionals just the obsessive-compulsive ones?</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=DKttZWjWLBQ:QLg62Prkuh0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=DKttZWjWLBQ:QLg62Prkuh0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=DKttZWjWLBQ:QLg62Prkuh0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=DKttZWjWLBQ:QLg62Prkuh0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=DKttZWjWLBQ:QLg62Prkuh0:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=DKttZWjWLBQ:QLg62Prkuh0:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/DKttZWjWLBQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/why-my-mom-and-ted-neward-irritate-me/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
