<?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:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0"><channel><title>John Teague's Blog</title><link>http://www.lostechies.com/blogs/johnteague/default.aspx</link><description>Take your finger off the F5 button, and slowly walk away.</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 (Build: 30929.2835)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/JohnTeague" type="application/rss+xml" /><item><title>Giving Your MVC Views an Identity</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/07/15/giving-your-mvc-views-an-identity.aspx</link><pubDate>Wed, 15 Jul 2009 05:01:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:22952</guid><dc:creator>jcteague</dc:creator><slash:comments>12</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=22952</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/07/15/giving-your-mvc-views-an-identity.aspx#comments</comments><description>&lt;p&gt;One of the great CSS tips I got from &lt;a href="http://bit.ly/19HYXY"&gt;Zen of CSS&lt;/a&gt; was to put an id on the body tag of your html pages.&amp;nbsp; This makes it really easy to use one CSS file for your entire site (a optimization trick) and allow you to target elements on specific page easily without creating a lot of unnecessary content wrappers or bogey class names.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;It is also very simple thing to do on MVC sites. Using the convention of Controller+Action give an easy identifier (if you&amp;rsquo;re using areas or something else you will need to tweak this a little).&amp;nbsp; This simple extension method does all the work for you.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="padding:5px;width:859px;display:block;float:none;margin-left:auto;margin-right:auto;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:17da7cd8-2f2e-4611-a865-e3de7a192786" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border:#000080 1px solid;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt;
&lt;div style="background-color:#ffffff;max-height:auto;overflow:scroll;padding:2px 5px;white-space:nowrap;"&gt;
&lt;p&gt;  &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MasterPageExtensions&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; BuildPageIdentifier(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ViewMasterPage&lt;/span&gt; masterPage,&amp;nbsp;&amp;nbsp;&lt;span style="color:#2b91af;"&gt;ViewContext&lt;/span&gt; context)&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt; &lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#a31515;"&gt;&amp;quot;{0}-{1}&amp;quot;&lt;/span&gt;, context.RouteData.Values[&lt;span style="color:#a31515;"&gt;&amp;quot;controller&amp;quot;&lt;/span&gt;],context.RouteData.Values[&lt;span style="color:#a31515;"&gt;&amp;quot;action&amp;quot;&lt;/span&gt;]);&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;\ &lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; Now just add this to your MasterPage.   &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="padding:5px;width:859px;display:block;float:none;margin-left:auto;margin-right:auto;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f7340f35-7c9d-4454-a185-99329ec2b3a2" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border:#000080 1px solid;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt;
&lt;div style="background-color:#ffffff;max-height:auto;overflow:scroll;padding:2px 5px;white-space:nowrap;"&gt;
&lt;p&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;body&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span&gt;= this.BuildPageIdentifier(this.ViewContext)&lt;/span&gt;&lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&amp;gt;&lt;br /&gt; &lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;It will create html that looks like this.&lt;/p&gt;
&lt;p&gt; &amp;lt;body id=&amp;rdquo;Resident-Edit&amp;rdquo;&amp;gt;&lt;/p&gt;
&lt;p&gt;Now you can write CSS like this to target specific pages on your site.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="padding:5px;width:859px;display:block;float:none;margin-left:auto;margin-right:auto;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f14e6002-538d-4bb6-8593-b9b441b71899" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border:#000080 1px solid;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt;
&lt;div style="background-color:#ffffff;max-height:300px;overflow:scroll;padding:2px 5px;white-space:nowrap;"&gt;
&lt;p&gt;  &lt;span style="color:#a31515;"&gt;#Resident-Edit&lt;/span&gt; &lt;span style="color:#a31515;"&gt;#VolumeLevel&lt;/span&gt; { &lt;span style="color:#ff0000;"&gt;display&lt;/span&gt;:&lt;span style="color:#0000ff;"&gt;block&lt;/span&gt;; &lt;span style="color:#ff0000;"&gt;margin-bottom&lt;/span&gt;:&lt;span style="color:#0000ff;"&gt;.8em&lt;/span&gt;; }
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Giving+Your+MVC+Views+an+Identity&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f07%2f15%2fgiving-your-mvc-views-an-identity.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f07%2f15%2fgiving-your-mvc-views-an-identity.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=22952" width="1" height="1"&gt;</description><category domain="http://www.lostechies.com/blogs/johnteague/archive/tags/MVC/default.aspx">MVC</category><category domain="http://www.lostechies.com/blogs/johnteague/archive/tags/CSS/default.aspx">CSS</category></item><item><title>Programming Basics: The for loop can do more than increment an integer</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/06/12/programming-basics-the-for-loop-can-do-more-than-increment-an-integer.aspx</link><pubDate>Fri, 12 Jun 2009 18:50:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:21861</guid><dc:creator>jcteague</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=21861</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/06/12/programming-basics-the-for-loop-can-do-more-than-increment-an-integer.aspx#comments</comments><description>&lt;p&gt;This is one of those small things that is easy to forget.&amp;nbsp; Usually when we use a for loop, we&amp;#39;ll just incrment over an integer so that we can get a specific item out of some iteration.&amp;nbsp; But you can do much more than that.&amp;nbsp; My current project has a complicated scheduling component and I&amp;#39;m often working with a range of dates.&amp;nbsp; I often need to do something with the days between two dates.&amp;nbsp; I created a TimePeriod class that is created with a start and end date.&lt;/p&gt;
&lt;p&gt;public class TimePeriod&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private readonly DateTime _start;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private readonly DateTime _end;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public TimePeriod(DateTime start, DateTime end)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _start = start;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _end = end;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Now what I need to do is iterate over all of the days that are between these two dates.&amp;nbsp; I was struggling with this for a while, trying get a clean implementation.&amp;nbsp; Then I remembered that the for loop could do this for me.&amp;nbsp; Instead of using the standard i++ of the loop action, I add a day to the iteration variable.&amp;nbsp; Now I can get every day between the start and end date.&lt;/p&gt;
&lt;p&gt;public IEnumerable&amp;lt;DateTime&amp;gt; DaysInPeriod()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(var d = _start; d &amp;lt;= _end; d = d.AddDays(1))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yield return d;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;Once I had this in place, I was able to put on some more convenience methods to cut down on some repetitive tasks I was performing.&lt;/p&gt;
&lt;p&gt;public bool Contains(DateTime dateTime)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return DaysInPeriod().Contains(dateTime);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public bool ContainsTheDayOfWeek(DayOfWeek dayOfWeek)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return DaysInPeriod().Any(d =&amp;gt; d.DayOfWeek == dayOfWeek);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;This was nothing Earth shattering, but a real simple abstraction made my life a lot easier.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Programming+Basics%3a+The+for+loop+can+do+more+than+increment+an+integer&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f06%2f12%2fprogramming-basics-the-for-loop-can-do-more-than-increment-an-integer.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f06%2f12%2fprogramming-basics-the-for-loop-can-do-more-than-increment-an-integer.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=21861" width="1" height="1"&gt;</description></item><item><title>Ruby and Rake as an executable</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/06/10/ruby-and-rake-as-an-executable.aspx</link><pubDate>Wed, 10 Jun 2009 20:05:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:21744</guid><dc:creator>jcteague</dc:creator><slash:comments>6</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=21744</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/06/10/ruby-and-rake-as-an-executable.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;ve been trying for months to get my partner in &lt;a href="http://www.nextleveltechnology.com"&gt;crime&lt;/a&gt;,&lt;a href="http://www.stephenbalkum.com"&gt; Stephen Balkum&lt;/a&gt;, to switch to Rake as our default build system.&amp;nbsp; We&amp;#39;ve been using Nant FOREVER and while it works, I really hate writing Nant scripts.&lt;/p&gt;
&lt;p&gt;The problem Stephen had with going to Rake where twofold.&amp;nbsp; One, we&amp;#39;re still doing (mostly) .Net apps, so the only thing we&amp;#39;d use Ruby for right now is Rake (hopefully that will change soon too).&amp;nbsp; And Ruby is a pretty big installation if you&amp;#39;re only building .Net projects with Rake.&lt;/p&gt;
&lt;p&gt;The other, more important, more problem is that we like to have completely self-contained projects.&amp;nbsp; So when a new dev comes online all they have to do is checkout from source control, click build.bat and you are ready to go.&amp;nbsp; You simply can&amp;#39;t do that with Ruby and Rake.&amp;nbsp; You must install Ruby and then get all of the gems necessary to run Rake.&lt;/p&gt;
&lt;p&gt;Well, Stephen found a way around all of this.&amp;nbsp; He has encapsulated Ruby, Rake, and all dependencies into a single 3mb executable.&amp;nbsp; Now it can be checked in and passed around like any other required tool.&lt;/p&gt;
&lt;p&gt;You can read more about it &lt;a href="http://www.stephenbalkum.com/archive/2009/06/09/when-all-you-need-is-a-rake.aspx"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Ruby+and+Rake+as+an+executable&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f06%2f10%2fruby-and-rake-as-an-executable.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f06%2f10%2fruby-and-rake-as-an-executable.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=21744" width="1" height="1"&gt;</description></item><item><title>Austin Code Camp Schedule</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/05/24/austin-code-camp-schedule.aspx</link><pubDate>Sun, 24 May 2009 20:39:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:21207</guid><dc:creator>jcteague</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=21207</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/05/24/austin-code-camp-schedule.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.lostechies.com/blogs/hex/archive/2009/05/16/austin-code-camp-sessions-voting-results.aspx"&gt;Several&lt;/a&gt; &lt;a href="http://www.lostechies.com/blogs/chad_myers/archive/2009/05/17/austin-codecamp-09-quite-possibly-better-than-bacon.aspx"&gt;people&lt;/a&gt; &lt;a href="http://devlicious.com/blogs/anne_epstein/archive/2009/05/17/austin-code-camp-2009.aspx"&gt;have&lt;/a&gt; already mentioned some of the sessions at this year&amp;#39;s Austin Code Camp. We&amp;#39;ve&lt;a title="Austin Code Camp 09" href="http://www.adnug.org/austincodecamp09"&gt; posted the schedule&lt;/a&gt; for people to view.&amp;nbsp; We may move some around depending on how the &lt;a title="Vote for sessions" href="http://www.adnug.org/AustinCodeCamp09/Proposal/List"&gt;voting&lt;/a&gt; goes to make sure there is adequate space for each session.&amp;nbsp; So be sure and check again at the conference.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m really excited about this year&amp;#39;s line up.&amp;nbsp; I think it&amp;#39;s a good mix of nuts and bolts framework usage and best practices &amp;amp; improving your craft style presentations.&lt;/p&gt;
&lt;p&gt;As always, the Austin Code Camp is completely free, including food.&amp;nbsp; We are able to do this by the awesome presenters who volunteer their time deliver this information and to our sponosors who help with actual expenses.&lt;/p&gt;
&lt;p&gt;If you haven&amp;#39;t registered yet, please hurry up and do so. We want to make sure we order enough food for everyone.&lt;/p&gt;
&lt;p&gt;I hope to see your there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Austin+Code+Camp+Schedule&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f05%2f24%2faustin-code-camp-schedule.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f05%2f24%2faustin-code-camp-schedule.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=21207" width="1" height="1"&gt;</description></item><item><title>Submit Your Austin Code Camp Sessions Now</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/04/17/submit-your-austin-code-camp-sessions-now.aspx</link><pubDate>Fri, 17 Apr 2009 05:27:52 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:20359</guid><dc:creator>jcteague</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=20359</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/04/17/submit-your-austin-code-camp-sessions-now.aspx#comments</comments><description>&lt;p&gt;The deadline for submitting session is April 19.&amp;#160; If you want to speak at this year’s code camp, better hurry up.&amp;#160; We have about 27 sessions submitted so far, most of them 2 hours in length.&amp;#160; Also remember, I don’t reject submissions unless I am out of space, which is very unlikely.&amp;#160; So if you submit multiple sessions be prepared to do all of them.&lt;/p&gt;  &lt;p&gt;For more details on Submitting Session, check out the original &lt;a href="http://www.lostechies.com/blogs/johnteague/archive/2009/02/17/austin-code-camp-09-call-for-speakeres.aspx"&gt;Call For Speakers&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Also it’s not too &lt;a href="http://www.adnug.org/AustinCodeCamp09/"&gt;Register&lt;/a&gt; or &lt;a href="http://austincodecamp.blogspot.com/2009/02/austin-code-camp-call-for-sponsors.html"&gt;Sponsor&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Submit+Your+Austin+Code+Camp+Sessions+Now&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f04%2f17%2fsubmit-your-austin-code-camp-sessions-now.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f04%2f17%2fsubmit-your-austin-code-camp-sessions-now.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=20359" width="1" height="1"&gt;</description></item><item><title>Building Maintainable Web Applications Training Course</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/04/15/building-maintainable-web-applications-training-course.aspx</link><pubDate>Thu, 16 Apr 2009 03:54:42 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:20328</guid><dc:creator>jcteague</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=20328</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/04/15/building-maintainable-web-applications-training-course.aspx#comments</comments><description>&lt;p&gt;I am conducting a two day training workshop on Building Maintainable Web Applications.&amp;#160; It will be here in Austin TX June 8-9.&lt;/p&gt;  &lt;p&gt;The foundational philosophy I and my consulting company believe is that creating applications that are maintainable starts with creating applications that are easy to test.&amp;#160; This workshop will show you how to apply design and testing techniques to web applications on the ASP.Net Framework.&amp;#160; I am definitely not talking for two days straight, so there will be a lot of hands on experience applying the concepts discussed.&lt;/p&gt;  &lt;p&gt;Some of the topics we will be covering include:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Designing Applications for Testability&lt;/li&gt;    &lt;li&gt;Unit Testing Strategies&lt;/li&gt;    &lt;li&gt;Model View Presenter for ASP.Net WebForms&lt;/li&gt;    &lt;li&gt;Asp.Net MVC Framework&lt;/li&gt;    &lt;li&gt;Automated Acceptance Testing of Web Applications&lt;/li&gt;    &lt;li&gt;Testing JavaScript&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The training course is designed for those that have existing ASP.Net 2.0 applications that must extend their lifetime and are also interested in new techniques available, such as the MVC Framework.&lt;/p&gt;  &lt;p&gt;The purpose of this training is as much about helping the developer community enhance their skills as anything else.&amp;#160; The cost for the entire 2 day workshop is only $200 so that we can cover our costs.&lt;/p&gt;  &lt;p&gt;If you have any questions or would like to attend, please contact me through this blog.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Building+Maintainable+Web+Applications+Training+Course&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f04%2f15%2fbuilding-maintainable-web-applications-training-course.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f04%2f15%2fbuilding-maintainable-web-applications-training-course.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=20328" width="1" height="1"&gt;</description></item><item><title>Resharper templates: Don't forget the Macros</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/04/06/resharper-templates-don-t-forget-the-macros.aspx</link><pubDate>Mon, 06 Apr 2009 04:36:17 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:20148</guid><dc:creator>jcteague</dc:creator><slash:comments>4</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=20148</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/04/06/resharper-templates-don-t-forget-the-macros.aspx#comments</comments><description>&lt;p&gt;I use Resharper templates (among other features) on a daily basis.&amp;#160; Most of them create very small pieces of code that I use VERY frequently.&amp;#160; For instance, I have a set of templates that help me build out my test classes and cases very quickly.&amp;#160; One of the very cool features you can add to your templates is to use Macros that let&amp;#39;s R# do more work for you.&lt;/p&gt;  &lt;p&gt;The lates template I created was to create the MockRepository.GenerateStub&amp;lt;Type&amp;gt;() line for me.&amp;#160; It’s a simple one liner, with one variable $INTERFACE$&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.lostechies.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/johnteague/image_5F00_0D55C0C2.png"&gt;&lt;img title="image" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="46" alt="image" src="http://www.lostechies.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/johnteague/image_5F00_thumb_5F00_0CE98DCD.png" width="721" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I then added a Macro to the template to guess the type the variable should be.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.lostechies.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/johnteague/image_5F00_35F42CC9.png"&gt;&lt;img title="image" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="375" alt="image" src="http://www.lostechies.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/johnteague/image_5F00_thumb_5F00_1815A8C8.png" width="347" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now I can use this macro ( it’s named gs) on this line.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.lostechies.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/johnteague/image_5F00_4E865ACA.png"&gt;&lt;img title="image" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="63" alt="image" src="http://www.lostechies.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/johnteague/image_5F00_thumb_5F00_351E5790.png" width="593" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;And it fills out the generic type of the GenerateStub method for me.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.lostechies.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/johnteague/image_5F00_0C164945.png"&gt;&lt;img title="image" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="31" alt="image" src="http://www.lostechies.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/johnteague/image_5F00_thumb_5F00_274EA246.png" width="913" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;As you can see, this is really a big time saver, especially for the really tedious generic types.&amp;#160; Small time optimizations like these add up over a few hundred tests.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Resharper+templates%3a+Don%27t+forget+the+Macros&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f04%2f06%2fresharper-templates-don-t-forget-the-macros.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f04%2f06%2fresharper-templates-don-t-forget-the-macros.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=20148" width="1" height="1"&gt;</description><category domain="http://www.lostechies.com/blogs/johnteague/archive/tags/resharper/default.aspx">resharper</category></item><item><title>Cooking With Pablo: Chicken Cacciatore</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/04/01/cooking-with-pablo-chicken-cacciatore.aspx</link><pubDate>Wed, 01 Apr 2009 05:03:22 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:20104</guid><dc:creator>jcteague</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=20104</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/04/01/cooking-with-pablo-chicken-cacciatore.aspx#comments</comments><description>&lt;p&gt;&lt;img style="display:inline;margin:5px;" height="192" src="http://farm1.static.flickr.com/46/108501892_47a04b87ce.jpg?v=0" width="256" align="left" alt="" /&gt; In this edition of Cooking With Pablo, were going to do one of my favorite one pot dishes: Chicken Cacciatore.&amp;#160; Cacciatore means “hunters stew”.&amp;#160; This would be a dish that hunters would make while on long hunting trips with whatever game they caught cooked with whatever vegetables were available.&amp;#160; Today it more traditionally served with a tomato sauce over pasta or rice.&lt;/p&gt;  &lt;h2&gt;&amp;#160;&lt;/h2&gt;  &lt;h2&gt;&amp;#160;&lt;/h2&gt;  &lt;h2&gt;&amp;#160;&lt;/h2&gt;  &lt;h2&gt;&amp;#160;&lt;/h2&gt;  &lt;h2&gt;Ingredients&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;About 1 lb of chicken.&amp;#160; I prefer using thighs or other dark meat, but chicken *** will work too&lt;/li&gt;    &lt;li&gt;2 cans of stewed tomatoes.&lt;/li&gt;    &lt;li&gt;1 small onion, diced&lt;/li&gt;    &lt;li&gt;As much garlic as you like, this is a lot for me&lt;/li&gt;    &lt;li&gt;Fresh Basil&lt;/li&gt;    &lt;li&gt;Thyme&lt;/li&gt;    &lt;li&gt;Oregano&lt;/li&gt;    &lt;li&gt;Salt and Pepper&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In a large skillet, brown the chicken in some olive oil over medium heat.&amp;#160; You just need to brown the sides, so 4-5 minutes on each side.&amp;#160; Remove the chicken from the skillet,add the onion and reduce the heat.&amp;#160; Sauté the onion until slightly caramelized.&amp;#160; Then add the tomatoes, garlic, basil, thyme and oregano.&amp;#160; Allow the sauce to simmer for 5 minutes or so, then use a potato masher to crush the tomatoes.&amp;#160; Add the chicken back to the pot and simmer for about 45 minutes or until the chicken is done.&amp;#160; Serve over pasta or rice with grated parmesan cheese.&lt;/p&gt;  &lt;h2&gt;Variations&lt;/h2&gt;  &lt;p&gt;Add mushroom, red peppers or whatever vegetables you like or are handy.&lt;/p&gt;  &lt;p&gt;Add about 1/2 cup of dry white wine and reduce for a brighter sauce.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Cooking+With+Pablo%3a+Chicken+Cacciatore&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f04%2f01%2fcooking-with-pablo-chicken-cacciatore.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f04%2f01%2fcooking-with-pablo-chicken-cacciatore.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=20104" width="1" height="1"&gt;</description><category domain="http://www.lostechies.com/blogs/johnteague/archive/tags/april-fools/default.aspx">april-fools</category></item><item><title>The MVC Template Team Got It Right</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/02/20/the-mvc-template-team-got-it-right.aspx</link><pubDate>Fri, 20 Feb 2009 16:04:22 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:18620</guid><dc:creator>jcteague</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=18620</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/02/20/the-mvc-template-team-got-it-right.aspx#comments</comments><description>&lt;p&gt;I just created my first project with ASP.Net MVC RC1 and I had a pleasant surprise!!&lt;/p&gt;  &lt;p&gt;As with the beta, when you create a new project with the MVC project template, it creates a AccountConroller as part of the startup code.&amp;#160; In the beta, all of the logic to handle user login and authentication was directly in the Action method.&amp;#160; This completely violates Separation of Concerns.&lt;/p&gt;  &lt;p&gt;With RC1 this code looks much better, they created IFormAuthentication and IMembershipService interfaces and added them to the constructor (for constructor dependency injection) and now all work is delegated to these interfaces.&lt;/p&gt;  &lt;p&gt;Kudus MVC team!! This is the correct design for both SoC and for testing purposes.&amp;#160; For RTM, could you also include the correct unit tests for this controller to further reinforce the need for testing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=The+MVC+Template+Team+Got+It+Right&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f02%2f20%2fthe-mvc-template-team-got-it-right.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f02%2f20%2fthe-mvc-template-team-got-it-right.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=18620" width="1" height="1"&gt;</description></item><item><title>Polymorphism with JavaScript</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/02/18/polymorphism-with-javascript.aspx</link><pubDate>Wed, 18 Feb 2009 05:20:12 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:17981</guid><dc:creator>jcteague</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=17981</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/02/18/polymorphism-with-javascript.aspx#comments</comments><description>&lt;p&gt;I don’t know if I picked this line up in a book or somewhere else, but the best way to describe the JavaScript language is schizophrenic.&amp;#160; The language itself (regardless of the hosting environment) doesn’t know if it’s Object Oriented or Functional.&amp;#160; It’s always been my opinion that the functional aspects of the language are more powerful than the OO features, yet the least used.&amp;#160; This is probably my most classically trained OOP developers don’t really like JavaScript. The other reason is because most classically trained OOP developers coming from .Net and Java ( myself included) also forget that JavaScript is also a &lt;em&gt;dynamic&lt;/em&gt; language.&amp;#160; So we try to get the language do things statically as we would expect other “grown up” languages to do.&lt;/p&gt;  &lt;p&gt;This is why a lot JavaScript libraries try to add additional layers on top of the language to make it feel more like a static language.&amp;#160;&amp;#160; Polymorphism is one of those features we expect from an Object Oriented language, yet the language itself doesn’t directly support this the way we expect it to (there are workarounds, but I’m not going into those).&amp;#160; But when you remember that JavaScript is dynamic, it become remarkably easy.&lt;/p&gt;  &lt;p&gt;In our current project, we are using JQuery to make modifications to a legacy web application, where we REALLY don’t want to work on the server-side logic.&amp;#160; In this app we have two form that are exactly the same (for our purposes at least) except for one little detail.&amp;#160; On one page, a critical piece of information is in a drop down list, while on the other page, it just static html content.&amp;#160; So we need a little polymorphic behavior here, to retrieve this information differently.&lt;/p&gt;  &lt;p&gt;To start with, we are using the &lt;a href="http://yuiblog.com/blog/2007/06/12/module-pattern/"&gt;Module Pattern&lt;/a&gt; to both contain our public methods in a single scope and to hide some of our methods from the public api.&amp;#160; So we exposed a method in our return object that we expect to override.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div&gt;   &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; module = &lt;span style="color:#0000ff;"&gt;function&lt;/span&gt;(){
 &lt;span style="color:#008000;"&gt;// private methods&lt;/span&gt;
 &lt;span style="color:#008000;"&gt;//return object that has our public methods&lt;/span&gt;
 &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;{
   getImportantField: &lt;span style="color:#0000ff;"&gt;function&lt;/span&gt;(){ alert(&lt;span style="color:#006080;"&gt;&amp;quot;this method is not implement, write your own&amp;quot;&lt;/span&gt;}
 }
}();&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;On the page where we need to get this from the drop down list, we include these script files:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;src&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Module.js&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&amp;lt;script type=&lt;span class="str"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; src=&lt;span class="str"&gt;&amp;quot;GetImportantFieldFromDropDown.js&amp;quot;&lt;/span&gt;&amp;gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Now we can change the behavior of our method my replacing it at runtime.&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;module.getImportantField = &lt;span style="color:#0000ff;"&gt;function&lt;/span&gt;(){
    &lt;span style="color:#008000;"&gt;//access the field via the drop down&lt;/span&gt;
}&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;And on the page where we need it from the text, we’ll include another file that changes the behavior of the method in question&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;src&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Module.js&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; 
&amp;lt;script type=&lt;span class="str"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; src=&lt;span class="str"&gt;&amp;quot;GetImportantFieldFromDropDown.js&amp;quot;&lt;/span&gt;&amp;gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;


&lt;p&gt;And of course change the behavior appropriately:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div&gt;
  &lt;pre class="csharpcode"&gt;module.getImportantField = &lt;span class="kwrd"&gt;function&lt;/span&gt;(){
    &lt;span class="rem"&gt;//access the field via the html text&lt;/span&gt;
}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This approach takes advantage of the fact that browsers load source files in the order in which they are listed.&amp;#160; Also the fact that JavaScript treats methods like variables and you can replace their value at any time.&amp;#160; This opens up many new opportunities for structuring your code in dynamic languages that are not possible with static languages. Yes I know you can do similar things with delegates in C#, but you get my point.&amp;#160; I’m still learning what is possible with dynamic languages and utilize that to its fullest extent.&amp;#160; &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Polymorphism+with+JavaScript&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f02%2f18%2fpolymorphism-with-javascript.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f02%2f18%2fpolymorphism-with-javascript.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=17981" width="1" height="1"&gt;</description><category domain="http://www.lostechies.com/blogs/johnteague/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Austin Code Camp 09 Call For Speakers</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/02/17/austin-code-camp-09-call-for-speakeres.aspx</link><pubDate>Wed, 18 Feb 2009 01:51:46 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:17945</guid><dc:creator>jcteague</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=17945</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/02/17/austin-code-camp-09-call-for-speakeres.aspx#comments</comments><description>&lt;h3&gt;When: May 30, 2009 – 8:30 AM – 5PM   &lt;br /&gt;Where: St. Edwards professional learning center, Austin, TX&lt;/h3&gt;  &lt;p&gt;The Austin .Net Users Group is hosting its fourth Code Camp. This one day, community driven conference has grown beyond the Austin community to a regional event with attendees from Texas, Louisiana, Arkansas &amp;amp; Oklahoma. Code Camp is &lt;i&gt;for&lt;/i&gt; developers &lt;i&gt;by&lt;/i&gt; developers, and we need you to help make this year’s event the best ever.&lt;/p&gt;  &lt;p&gt;We are looking for presenters and session leaders to help educate the Austin .Net community and beyond. Sessions should be focus on software development practices and techniques that will have an immediate impact.&lt;/p&gt;  &lt;h3&gt;Session Length&lt;/h3&gt;  &lt;p&gt;To make sure that attendees get the most from your session, the length of the session will not be limited to one hour. Your session can be 1, 2, or 4 hours long. This gives you the freedom to dive deep into your subject matter and allow for discussion and dialog with attendees.&lt;/p&gt;  &lt;p&gt;&lt;i&gt;We encourage you to think outside of the traditional 1 hour presentation format and be creative with your presentation so that attendees have the opportunity to truly comprehend the topic.&lt;/i&gt;&lt;/p&gt;  &lt;h3&gt;Session formats&lt;/h3&gt;  &lt;p&gt;&lt;b&gt;Code focused presentation&lt;/b&gt; – These are presentations that include both a little power point and a lot of code demos. Given the audience that is attending it is important that a large amount of the presentation is focused on code and coding related techniques.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Chalk Talks / Fish Bowl Discussions&lt;/b&gt; – These sessions are designed as a facilitated discussion around a developer topic. They are presented as a free form facilitated discussion that leverages the expertise of the presenter and the combined knowledge of the group to explore a specific topic.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Hands-on-labs – &lt;/b&gt;St. Edwards has a computer lab available at the facility, so this gives us the opportunity to explore a hands-on-lab option.&lt;/p&gt;  &lt;h3&gt;No Session Tracks&lt;/h3&gt;  &lt;p&gt;There will be no defined session tracks. Your topic can be on anything you think will interest .Net Developers (even if it’s not about .Net). Topics can include, but are not limited to:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;General Development - &lt;/b&gt;This is a track that discusses general best practices for software development not tied to a specific application library or framework. Possible topics would be design patterns, testing strategies, specific language features (LINQ, generics).&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Smart Client&lt;/b&gt; – This track is designed for topics related to Smart Client related development topics. This includes Windows Forms and Windows Presentation Framework applications, Microsoft Office or mobile devices.&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Web Track&lt;/b&gt; – This track is designed for topics about Web based development that includes ASP.NET, MVC Framework, AJAX, and Web Services.&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Project Management – &lt;/b&gt;This track is designed for presentations and chalk talks that include development process fundamentals and project planning activities such as size estimation, requirements gathering, etc.&lt;/li&gt;    &lt;li&gt;&lt;b&gt;User Experience&lt;/b&gt; -- Covers key disciplines that help bring users directly into your process and reap the rewards of effective, efficient and productive technology solutions, including UX Strategy, Usability Testing, Creative Design, Information Architecture and Design Technology. &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Submission Deadline: April 17, 2009&lt;/h3&gt;  &lt;p&gt;Submit all sessions on the website http:// www.austincodecamp.com&lt;b&gt; &lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Once your outline is received, we will review and provide scheduling for the selected sessions. &lt;/p&gt;  &lt;p&gt;All slides and materials will be stored in the AustinCodeCamp09 google code website.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;http://code.google.com/p/austincodecamp09/&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Once we receive your submission, we will make grant you access to the repository.&amp;#160; &lt;b&gt;You must have a Google account to submit your materials&lt;/b&gt;. &lt;/p&gt;  &lt;p&gt;The following information is required when submitting your session&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Name:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Company:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Email:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Phone:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Website / Blog:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Session Length&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Session Type:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Session Name:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Session Description:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;     &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Appendix A. - Code Camp Manifesto &lt;/p&gt;  &lt;p&gt;(&lt;a href="http://www.bostondotnet.org/CodeCamp/default.aspx/CodeCamp/CodeCamp%20Manifesto.html"&gt;http://www.bostondotnet.org/CodeCamp/default.aspx/CodeCamp/CodeCamp%20Manifesto.html&lt;/a&gt;)&lt;/p&gt;  &lt;p&gt;The original Code Camp was a conglomeration of ideas by many different people across the development community. The idea was simple provide an off hour forum for the development community to speak and share ideas for them to come and enjoy. The results have been astounding. I am happy to report that they are being planned across many different cities. &lt;/p&gt;  &lt;h4&gt;The question is what makes a Code Camp? &lt;/h4&gt;  &lt;p&gt;The answer is actually simple. In order to use the official Code Camp name and banner follow these simple protocols. &lt;/p&gt;  &lt;h4&gt;By and For the Developer Community&lt;/h4&gt;  &lt;p&gt;Code Camps are about the developer community at large. They are meant to be a place for developers to come and learn from their peers. Topics are always based on community interest and never determined by anyone other than the community.&lt;/p&gt;  &lt;h4&gt;Always Free&lt;/h4&gt;  &lt;p&gt;Code Camps are always free for attendees.&lt;/p&gt;  &lt;h4&gt;Community Developed Material&lt;/h4&gt;  &lt;p&gt;The success of the Code Camps is that they are based on community content. All content that is delivered is original. All presentation content must be provided completely (including code) without any restriction. If you have content you don&amp;#39;t want to share or provide to attendees then the Code Camp is not the place for you.&lt;/p&gt;  &lt;h4&gt;No Fluff only Code&lt;/h4&gt;  &lt;p&gt;Code Camps are about showing the code. Refer to rule #1 if you have any questions on this. &lt;/p&gt;  &lt;h4&gt;Community Ownership&lt;/h4&gt;  &lt;p&gt;The most important element of the Code Camp is always the developer community. All are welcome to attend and speak and do so without expectation of payment or any other compensation other than their participation in the community.&lt;/p&gt;  &lt;h4&gt;Never occur during work hours&lt;/h4&gt;  &lt;p&gt;We need to understand that many times people can&amp;#39;t leave work for a day or two to attend training or even seminars. The beauty of the Code Camp is that they always occur on weekends.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Austin+Code+Camp+09+Call+For+Speakers&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f02%2f17%2faustin-code-camp-09-call-for-speakeres.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f02%2f17%2faustin-code-camp-09-call-for-speakeres.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=17945" width="1" height="1"&gt;</description></item><item><title>Another Way to Test Ajax Methods</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/02/10/another-way-to-test-ajax-methods.aspx</link><pubDate>Tue, 10 Feb 2009 05:47:45 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:16377</guid><dc:creator>jcteague</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=16377</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/02/10/another-way-to-test-ajax-methods.aspx#comments</comments><description>&lt;p&gt;A while ago, &lt;a href="http://chadmyers.lostechies.com"&gt;Chad&lt;/a&gt; posted about how to &lt;a href="http://www.lostechies.com/blogs/chad_myers/archive/2008/12/22/asynchronous-javascript-testing-with-qunit.aspx"&gt;test Ajax methods with QUnit&lt;/a&gt;.&amp;#160; I’m also testing Ajax calls, but taking a different approach I thought I would share.&lt;/p&gt;  &lt;p&gt;Chad’s approach was to put a timer in the test and waiting a while before performing the assertion.&amp;#160; Another way is to hook into JQuery global ajax events, like the ajaxComplete event.&amp;#160; Here’s some sample code that makes a call to the Flickr API via jsonp.&lt;/p&gt;  &lt;div&gt;   &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; url = &lt;span style="color:#006080;"&gt;&amp;quot;http://api.flickr.com/services/feeds/photos_public.gne?tags=austin,tx&amp;amp;format=json&amp;amp;jsoncallback=?&amp;quot;&lt;/span&gt;;

$(document).ready(&lt;span style="color:#0000ff;"&gt;function&lt;/span&gt;(){
    test(&lt;span style="color:#006080;"&gt;&amp;quot;should get results from getJson call&amp;quot;&lt;/span&gt;,&lt;span style="color:#0000ff;"&gt;function&lt;/span&gt;(){
        expect(1);
        &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; results;
        $(document).ajaxComplete(&lt;span style="color:#0000ff;"&gt;function&lt;/span&gt;(){
            start();
            equals(results.title,&lt;span style="color:#006080;"&gt;&amp;quot;Recent Uploads tagged austin and tx&amp;quot;&lt;/span&gt;,&lt;span style="color:#006080;"&gt;&amp;quot;actual: &amp;quot;&lt;/span&gt; + results.title);
        });
        stop();
        $.getJSON(url,&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;,&lt;span style="color:#0000ff;"&gt;function&lt;/span&gt;(data){
            results = data;
        });
    })

});&lt;/pre&gt;
&lt;/div&gt;

&lt;h2&gt;Avoid Testing Ajax Calls in Unit Tests&lt;/h2&gt;

&lt;p&gt;Huh? You just showed me a way to do it, why should I avoid it?&amp;#160; Making an Ajax call is just like making a database call, which should only be done for integration style tests.&amp;#160; Just as you would stub a data repository method call in C#, you should do the same for AJAX calls.&amp;#160; Except in JavaScript, this is 10 time easier because of it’s a dynamic, functional language.&amp;#160; You can easily stub out method calls by replacing the method.&lt;/p&gt;

&lt;p&gt;In this case I am testing against the title property, so I need a stub that looks like the getJSON method and returns back the title property.&lt;/p&gt;

&lt;p&gt;Here is the same test, but with a stubbed out getJSON method.&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; stubbedJSON = &lt;span style="color:#0000ff;"&gt;function&lt;/span&gt;(url,data,callback,format){
        callback({title:&lt;span style="color:#006080;"&gt;&amp;quot;fake results&amp;quot;&lt;/span&gt;});
    };
    &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; originalJSON = $.getJSON;
    module(&lt;span style="color:#006080;"&gt;&amp;quot;stubbing out getJSON&amp;quot;&lt;/span&gt;, {setup: &lt;span style="color:#0000ff;"&gt;function&lt;/span&gt;(){
        $.getJSON = stubbedJSON;
    }, teardown: &lt;span style="color:#0000ff;"&gt;function&lt;/span&gt;(){
      $.getJSON = originalJSON;  
    }})
    test(&lt;span style="color:#006080;"&gt;&amp;quot;getJSON should be stubbed&amp;quot;&lt;/span&gt;,&lt;span style="color:#0000ff;"&gt;function&lt;/span&gt;(){
        expect(1);
        $.getJSON(url,&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;,&lt;span style="color:#0000ff;"&gt;function&lt;/span&gt;(data){
            equals(data.title,&lt;span style="color:#006080;"&gt;&amp;quot;fake results&amp;quot;&lt;/span&gt;);
        });
    });&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;One thing that I learned the hard way with QUnit tests is that whenever you stub a method, it stays stubbed for &lt;strong&gt;ALL &lt;/strong&gt;of the test on the test page.&amp;#160; To get around that, I store the original method in a variable, then reset the method manually in the teardown.&amp;#160; This keeps my changes isolated for each test.&lt;/p&gt;

&lt;p&gt;Now I’m able to test the logic of my JavaScript isolated from the data coming back from my data service.&amp;#160; Notice how easy it was to stub out the method.&amp;#160; No complicated mocking tool required.&amp;#160; One you embrace the dynamic&lt;em&gt;&lt;strong&gt; &lt;/strong&gt;and &lt;/em&gt;the functional nature of JavaScript, you can do a lot more with the language than you expected.&amp;#160; I’m appreciating JavaScript a lot more these days.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Another+Way+to+Test+Ajax+Methods&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f02%2f10%2fanother-way-to-test-ajax-methods.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f02%2f10%2fanother-way-to-test-ajax-methods.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=16377" width="1" height="1"&gt;</description></item><item><title>Austin Code Camp 09</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/02/09/austin-code-camp-09.aspx</link><pubDate>Tue, 10 Feb 2009 00:18:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:16346</guid><dc:creator>jcteague</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=16346</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/02/09/austin-code-camp-09.aspx#comments</comments><description>&lt;h2&gt;&lt;span style="color:#400080;"&gt;When: Saturday, May 30th&lt;/span&gt;&lt;/h2&gt;
&lt;h2&gt;&lt;span style="color:#400080;"&gt;Where: &lt;/span&gt;&lt;a href="http://www.pec.stedwards.edu/"&gt;&lt;span style="color:#400080;"&gt;St. Edwards Professional Education Center&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;We are gearing up for This Year&amp;rsquo;s Austin .Net User&amp;rsquo;s Group Code Camp.&amp;nbsp; Last year we had 300 attendees and around 30 sessions.&amp;nbsp; We expect this years to be even better.&amp;nbsp; Register and submit sessions at &lt;a href="http://www.austincodecamp.com"&gt;www.austincodecamp.com&lt;/a&gt; (thanks Eric)&lt;/p&gt;
&lt;h3&gt;Encouraging Deeper Understanding of Content&lt;/h3&gt;
&lt;p&gt;In year&amp;rsquo;s past, we followed the traditional session 1 hour presentation format used by most conferences.&amp;nbsp; As I&amp;rsquo;ve attended and speak more conferences, I am finding the one hour session both hindering my ability to adequately learn anything and my ability to deliver quality information. So this year we are doing something a little different.&amp;nbsp; &lt;b&gt;&lt;i&gt;Sessions will not be limited to one hour!!!&lt;/i&gt; &lt;/b&gt;Sessions will be 1,2,4 or 6 hours long.&amp;nbsp; Hopefully this will allow you to better comprehend the information being presented instead of being bombarded with new concepts&lt;/p&gt;
&lt;p&gt;You can contact me or &lt;a href="http://www.lostechies.com/blogs/hex/default.aspx"&gt;Eric Hexter&lt;/a&gt; if you have any questions.&lt;/p&gt;
&lt;p&gt;See you there!!!&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Please rebroadcast this message as loudly as possible!!&lt;/b&gt;&lt;/p&gt;
&lt;h3&gt;What is CodeCamp&lt;/h3&gt;
&lt;p&gt;&lt;a href="http://www.bostondotnet.org/CodeCamp/default.aspx/CodeCamp/CodeCamp%20Manifesto.html"&gt;http://www.bostondotnet.org/CodeCamp/default.aspx/CodeCamp/CodeCamp%20Manifesto.html&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;By and For the Developer Community&lt;/h4&gt;
&lt;p&gt;Code Camps are about the developer community at large. They are meant to be a place for developers to come and learn from their peers. Topics are always based on community interest and never determined by anyone other than the community.&lt;/p&gt;
&lt;h4&gt;Always Free&lt;/h4&gt;
&lt;p&gt;Code Camps are always free for attendees.&lt;/p&gt;
&lt;h4&gt;Community Developed Material&lt;/h4&gt;
&lt;p&gt;The success of the Code Camps is that they are based on community content. All content that is delivered is original. All presentation content must be provided completely (including code) without any restriction. If you have content you don&amp;#39;t want to share or provide to attendees then the Code Camp is not the place for you.&lt;/p&gt;
&lt;h4&gt;No Fluff only Code&lt;/h4&gt;
&lt;p&gt;Code Camps are about showing the code. Refer to rule #1 if you have any questions on this. &lt;/p&gt;
&lt;h4&gt;Community Ownership&lt;/h4&gt;
&lt;p&gt;The most important element of the Code Camp is always the developer community. All are welcome to attend and speak and do so without expectation of payment or any other compensation other than their participation in the community.&lt;/p&gt;
&lt;h4&gt;Never occur during work hours&lt;/h4&gt;
&lt;p&gt;We need to understand that many times people can&amp;#39;t leave work for a day or two to attend training or even seminars. The beauty of the Code Camp is that they always occur on weekends.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Austin+Code+Camp+09&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f02%2f09%2faustin-code-camp-09.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f02%2f09%2faustin-code-camp-09.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=16346" width="1" height="1"&gt;</description><category domain="http://www.lostechies.com/blogs/johnteague/archive/tags/codecamp/default.aspx">codecamp</category><category domain="http://www.lostechies.com/blogs/johnteague/archive/tags/adnug/default.aspx">adnug</category></item><item><title>Google’s Testers take on Dependency Injection</title><link>http://www.lostechies.com/blogs/johnteague/archive/2009/01/20/google-s-testers-take-on-dependency-injection.aspx</link><pubDate>Wed, 21 Jan 2009 00:27:11 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:14358</guid><dc:creator>jcteague</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=14358</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2009/01/20/google-s-testers-take-on-dependency-injection.aspx#comments</comments><description>&lt;p&gt;If you’re not already subscribing to the &lt;a href="http://googletesting.blogspot.com/"&gt;Google Testing Blog&lt;/a&gt;, you should be.&amp;#160; There are some really interesting articles on it.&amp;#160; The latest one takes on if and &lt;a href="http://googletesting.blogspot.com/2009/01/when-to-use-dependency-injection.html"&gt;when to use Dependency Injection&lt;/a&gt;.&amp;#160; I agree with their answer: &lt;strong style="font-size:18px;"&gt;yes &lt;/strong&gt;and &lt;strong style="font-size:18px;"&gt;always!&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=Google%e2%80%99s+Testers+take+on+Dependency+Injection&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f01%2f20%2fgoogle-s-testers-take-on-dependency-injection.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2009%2f01%2f20%2fgoogle-s-testers-take-on-dependency-injection.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=14358" width="1" height="1"&gt;</description></item><item><title>PTOM: Bend 3rd Party Libraries to Your Will With the Adapter Pattern</title><link>http://www.lostechies.com/blogs/johnteague/archive/2008/11/25/ptom-bend-3rd-party-libraries-to-your-will-with-the-adapter-pattern.aspx</link><pubDate>Tue, 25 Nov 2008 05:43:00 GMT</pubDate><guid isPermaLink="false">ded273ab-9e87-4979-8222-e4e2e46f1b46:7382</guid><dc:creator>jcteague</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://www.lostechies.com/blogs/johnteague/rsscomments.aspx?PostID=7382</wfw:commentRss><comments>http://www.lostechies.com/blogs/johnteague/archive/2008/11/25/ptom-bend-3rd-party-libraries-to-your-will-with-the-adapter-pattern.aspx#comments</comments><description>&lt;p&gt;No matter what you do or where you work, there will always be the 3rd party library that your manager insists you use (you know, the one whose agreement was made on the golf course), or that old legacy code that is impossible to test.&amp;nbsp; Now it might be easy to just throw your hands up in desperation, but you can shield your code from this big ugly untestable tangle by hiding it so that you will never know you are using the library.&amp;nbsp; The easiest way is to use the &lt;a href="http://en.wikipedia.org/wiki/Adapter_pattern"&gt;Adapter Pattern&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The definition of the adapter pattern, from &lt;a href="http://c2.com/cgi/wiki?AdapterPattern"&gt;c2.com&lt;/a&gt; is: &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;i&gt;Convert&lt;/i&gt; the interface of some class &lt;i&gt;b&lt;/i&gt; into an interface &lt;i&gt;a&lt;/i&gt; that some client class &lt;i&gt;c&lt;/i&gt; understands.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Now this is definitely a very useful ability of this pattern, and can solve some problems very elegantly.&amp;nbsp; One area where I used this pattern with this strict definition was to convert messages from one logging framework to another.&amp;nbsp; But there is really much more potential behind this rather diminutive definition.&amp;nbsp; It allows you to hide whatever you want behind your own interface and only have to slay those 3rd party or legacy code dragons in one place.&amp;nbsp; Now the rest of your application go along it&amp;rsquo;s merrily way.&lt;/p&gt;
&lt;p&gt;Here is the UML for the Adapter pattern.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.lostechies.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/johnteague/image_5F00_5157213E.png"&gt;&lt;img title="image" style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" alt="image" src="http://www.lostechies.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/johnteague/image_5F00_thumb_5F00_6C8F7A3F.png" border="0" height="205" width="531" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;I got to be honest, generic class diagrams do me almost know good.&amp;nbsp; I&amp;rsquo;m just not one of those visual learners I guess.&amp;nbsp; Here&amp;rsquo;s what the code structure looks like.&lt;/p&gt;
&lt;div&gt;
&lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;background-color:#f4f4f4;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; ThereBeDragonsHere{&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; AMethodINeedToCallButCannotTest(xxx)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;interface&lt;/span&gt; IHideDragons{&lt;br /&gt;    WhatTheIntReallyMeans CallMeInsteadOfUglyOne(xxx);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; DragonHider : IHideDragons{&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; ThereBeDragonsHere _dragons;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; DragonHider(Dependency dep){&lt;br /&gt;        _dragons = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; ThereBeDragonsHere();&lt;br /&gt;        setupDragon(dep);&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; WhatTheIntReallyMeans CallMeInsteadOfUglyOne(xxx){&lt;br /&gt;        var answer = _dragons.AMethodINeedToCallButCannotTest(xxx);&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; correctTheAnswer(answer);&lt;br /&gt;         &lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Now the dragons are safely hidden. What&amp;rsquo;s more, you can transform the messages passed back and forth to the 3rd party library in whatever terminology that correctly defines the conversation in terms of your application. The rest of the application is now testable, mocking out your object when you need to.&lt;/p&gt;
&lt;p&gt;In the &lt;a href="http://www.lostechies.com/blogs/chad_myers/archive/2008/11/21/alt-net-online-open-meeting.aspx"&gt;online open meeting&lt;/a&gt; last week, someone asked how do you introduce testing into a legacy codebase.&amp;nbsp; In this case, the speaker said that in order to introduce TDD into an app, he needed to change about 30 classes and was unsure about the implications of the changes as well as the scope creep it put on his time estimate.&amp;nbsp; This is one way to introduce TDD into a code base &lt;a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2007/08/31/legacy-code-testing-techniques-subclass-and-override-non-virtual-members.aspx"&gt;is&lt;/a&gt; &lt;a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2007/10/19/dependency-breaking-techniques-inline-static-class.aspx"&gt;one&lt;/a&gt; technique that can help you get there.&amp;nbsp; Through &lt;a href="http://jamesshore.com/Articles/Technology/Continuous%20Design.abstract"&gt;continuous improvement&lt;/a&gt;, you will have a system that is testable and maintainable.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?title=PTOM%3a+Bend+3rd+Party+Libraries+to+Your+Will+With+the+Adapter+Pattern&amp;url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2008%2f11%2f25%2fptom-bend-3rd-party-libraries-to-your-will-with-the-adapter-pattern.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.lostechies.com%2fblogs%2fjohnteague%2farchive%2f2008%2f11%2f25%2fptom-bend-3rd-party-libraries-to-your-will-with-the-adapter-pattern.aspx" border="0" alt="Kick It on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://www.lostechies.com/aggbug.aspx?PostID=7382" width="1" height="1"&gt;</description><category domain="http://www.lostechies.com/blogs/johnteague/archive/tags/design+patterns/default.aspx">design patterns</category><category domain="http://www.lostechies.com/blogs/johnteague/archive/tags/PTOM/default.aspx">PTOM</category></item></channel></rss>
