<?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>Lazycoder</title>
	
	<link>http://www.lazycoder.com/weblog</link>
	<description />
	<lastBuildDate>Fri, 10 Jul 2009 10:05:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</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/Lazycoder" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>links for 2009-07-10</title>
		<link>http://www.lazycoder.com/weblog/2009/07/10/links-for-2009-07-10/</link>
		<comments>http://www.lazycoder.com/weblog/2009/07/10/links-for-2009-07-10/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 10:05:53 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/07/10/links-for-2009-07-10/</guid>
		<description><![CDATA[

JUDE Community Site &#8211; JUDE Developers Blog
(tags: lean process)


]]></description>
			<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://jude-users.com/en/modules/weblog/details.php?blog_id=61">JUDE Community Site &#8211; JUDE Developers Blog</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/Skoon/lean">lean</a> <a href="http://delicious.com/Skoon/process">process</a>)</div>
</li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Lazycoder?a=5BaPribiNMk:q1XIIa2kDAw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=5BaPribiNMk:q1XIIa2kDAw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=5BaPribiNMk:q1XIIa2kDAw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=5BaPribiNMk:q1XIIa2kDAw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=5BaPribiNMk:q1XIIa2kDAw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=5BaPribiNMk:q1XIIa2kDAw:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=5BaPribiNMk:q1XIIa2kDAw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=5BaPribiNMk:q1XIIa2kDAw:F7zBnMyn0Lo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2009/07/10/links-for-2009-07-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>links for 2009-07-09</title>
		<link>http://www.lazycoder.com/weblog/2009/07/09/links-for-2009-07-09/</link>
		<comments>http://www.lazycoder.com/weblog/2009/07/09/links-for-2009-07-09/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 10:14:48 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/07/09/links-for-2009-07-09/</guid>
		<description><![CDATA[

Meffifying Windows Azure &#8211; Glenn Block &#8211; CodeBetter.Com &#8211; Stuff you need to Code Better!
(tags: MEF .NET Azure)


]]></description>
			<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://codebetter.com/blogs/glenn.block/archive/2009/07/03/meffifying-windows-azure.aspx">Meffifying Windows Azure &#8211; Glenn Block &#8211; CodeBetter.Com &#8211; Stuff you need to Code Better!</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/Skoon/MEF">MEF</a> <a href="http://delicious.com/Skoon/.NET">.NET</a> <a href="http://delicious.com/Skoon/Azure">Azure</a>)</div>
</li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Lazycoder?a=-Q8GMGdO58E:_bRKEaIxUfs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=-Q8GMGdO58E:_bRKEaIxUfs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=-Q8GMGdO58E:_bRKEaIxUfs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=-Q8GMGdO58E:_bRKEaIxUfs:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=-Q8GMGdO58E:_bRKEaIxUfs:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=-Q8GMGdO58E:_bRKEaIxUfs:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=-Q8GMGdO58E:_bRKEaIxUfs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=-Q8GMGdO58E:_bRKEaIxUfs:F7zBnMyn0Lo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2009/07/09/links-for-2009-07-09/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>links for 2009-07-02</title>
		<link>http://www.lazycoder.com/weblog/2009/07/02/links-for-2009-07-02/</link>
		<comments>http://www.lazycoder.com/weblog/2009/07/02/links-for-2009-07-02/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 10:09:48 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/07/02/links-for-2009-07-02/</guid>
		<description><![CDATA[

Pimp my Gedit (Was: Textmate for Linux) &#124; Grigio.org &#8211; un blog critico su Linux Ubuntu, Tecnologia e altro
(tags: ruby rails textmate linux)


the { buckblogs :here }: Coming home to Vim
(tags: ruby vim)


]]></description>
			<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://grigio.org/pimp_my_gedit_was_textmate_linux">Pimp my Gedit (Was: Textmate for Linux) | Grigio.org &#8211; un blog critico su Linux Ubuntu, Tecnologia e altro</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/Skoon/ruby">ruby</a> <a href="http://delicious.com/Skoon/rails">rails</a> <a href="http://delicious.com/Skoon/textmate">textmate</a> <a href="http://delicious.com/Skoon/linux">linux</a>)</div>
</li>
<li>
<div class="delicious-link"><a href="http://weblog.jamisbuck.org/2008/10/10/coming-home-to-vim">the { buckblogs :here }: Coming home to Vim</a></div>
<div class="delicious-tags">(tags: <a href="http://delicious.com/Skoon/ruby">ruby</a> <a href="http://delicious.com/Skoon/vim">vim</a>)</div>
</li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Lazycoder?a=yx1Pg-e6Eec:3ImzrnLgJYM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=yx1Pg-e6Eec:3ImzrnLgJYM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=yx1Pg-e6Eec:3ImzrnLgJYM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=yx1Pg-e6Eec:3ImzrnLgJYM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=yx1Pg-e6Eec:3ImzrnLgJYM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=yx1Pg-e6Eec:3ImzrnLgJYM:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=yx1Pg-e6Eec:3ImzrnLgJYM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=yx1Pg-e6Eec:3ImzrnLgJYM:F7zBnMyn0Lo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2009/07/02/links-for-2009-07-02/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Great post by Cory Foy</title>
		<link>http://www.lazycoder.com/weblog/2009/06/10/great-post-by-cory-foy/</link>
		<comments>http://www.lazycoder.com/weblog/2009/06/10/great-post-by-cory-foy/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 03:25:44 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[agile projectManagement scrum]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/2009/06/10/great-post-by-cory-foy/</guid>
		<description><![CDATA[Cory Foy &#8211; Hope is not a Risk Management Strategy

What if the vendor can&#8217;t get the bug fix in time? It may not be vital early on, but the thought process behind an exit strategy should exist, and simply become more refined the closer we come to the risk event, instead of scrambling to make [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cornetdesign.com/2009/06/hope-is-not-risk-management-strategy.html">Cory Foy &#8211; Hope is not a Risk Management Strategy</a></p>
<blockquote cite="Cory Foy"><p>
What if the vendor can&#8217;t get the bug fix in time? It may not be vital early on, but the thought process behind an exit strategy should exist, and simply become more refined the closer we come to the risk event, instead of scrambling to make one appear when it is clear we aren&#8217;t going to make it.
</p></blockquote>
<p>We&#8217;ve all been there. You work your butt off and you know your code is good, but you don&#8217;t know much about the database or the stability of the enterprise library you have to call. The app architects keep saying the interfaces aren&#8217;t going to change but &#8230; they&#8217;ve done nothing but change in the 4 weeks leading up to your launch. What is your exit strategy? It could be that your backup plan is to present a nice error message to the user rather than an ugly stack trace. Maybe you just disable that component or inform the user that the data is read-only for now.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Lazycoder?a=H01bOuuHkQM:6kPzMyAAU64:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=H01bOuuHkQM:6kPzMyAAU64:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=H01bOuuHkQM:6kPzMyAAU64:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=H01bOuuHkQM:6kPzMyAAU64:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=H01bOuuHkQM:6kPzMyAAU64:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=H01bOuuHkQM:6kPzMyAAU64:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=H01bOuuHkQM:6kPzMyAAU64:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=H01bOuuHkQM:6kPzMyAAU64:F7zBnMyn0Lo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2009/06/10/great-post-by-cory-foy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Review: IronPython in Action</title>
		<link>http://www.lazycoder.com/weblog/2009/05/28/review-ironpython-in-action/</link>
		<comments>http://www.lazycoder.com/weblog/2009/05/28/review-ironpython-in-action/#comments</comments>
		<pubDate>Thu, 28 May 2009 14:44:04 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Book Review]]></category>
		<category><![CDATA[Languages]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1127</guid>
		<description><![CDATA[I&#8217;ve always wanted to use Python more but it&#8217;s difficult because the .NET Framework is such a walled garden in terms of interoperability with other programming languages. Mostly I use it to write little one off scripts when I want to move a bunch of files around or parse some text. I was really excited [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always wanted to use Python more but it&#8217;s difficult because the .NET Framework is such a walled garden in terms of interoperability with other programming languages. Mostly I use it to write little one off scripts when I want to move a bunch of files around or parse some text. I was really excited when Manning asked to to review IronPython in Action because I wanted to dive a little deeper into Python and possibly use it in some web applications. &#8220;IronPython in Action&#8221; makes it easy to get started using IronPython right away.</p>
<p>The book starts out with an introduction to Python itself and continues with a general description of how IronPython can use .NET types. It starts off by showing how to build a Winforms app using IronPython. If anything exposes the cruel, unnecessary complexity of .NET, it&#8217;s got to be a Winforms app. The IronPython examples are easy to follow and it&#8217;s always fun to create and manipulate a Winforms app using the IronPython console.</p>
<p>Chapter 4 talks about using Design patterns in IronPython. This is a refreshing change from most language books where patterns aren&#8217;t mentioned at all. The chapter builds an IronPython application and uses the MVC pattern for the overall architecture and the command pattern for the implementation of the menu bar events. </p>
<p>Chapter 7 discusses agile testing and unit testing using IronPython. I almost dropped the book in amazement. Unit testing is almost never mentioned in any language book and is relegated to a niche or advanced topic. Find a book about any other .NET language that mentions unit testing that doesn&#8217;t have the word &#8220;testing&#8221; in the title. This alone sets the quality of this book far above other language books I have read. It&#8217;s not just enough, in my opinion, to discuss the syntax of the language. You have to teach the reader how to use the language in your everyday work.</p>
<p>The next section, section3, deals with a few core UI frameworks commonly used during .NET development, WPF, Silverlight, and ASP.NET, as well as showing how you can use IronPython to administer your system. Performing tedious tasks is my most common use of IronPython. I use it to automate moving files that fit a specific pattern out of my &#8220;downloads&#8221; directory to their proper places. It was great to learn a few new techniques for using IronPython in Powershell.</p>
<p>The last section talks about extending IronPython using C#, something which it sounds like should be avoided unless you just can&#8217;t achieve decent performance with the equivalent IronPython code, and using IronPython as an embedde scripting engine. Python is used a lot in game programming because it&#8217;s easy to embed. The nuts and bolts of the game engine will be written in low-level C/Assembly while the game logic and story is written in Python. I love the idea of having an embedded scripting engine in my application that will allow me to quickly extend my application at runtime. The user need to perform a new calculation on some data?  Just send them an IronPython script and have them put it in a directory. It&#8217;s a great idea and the book describes exactly how to do just that, even if it does use a little too much jargon at times. These are advanced topics and you probably shouldn&#8217;t undertake them unless you have a good understanding of the basics in any case.</p>
<p>My overall feeling about this book is that it&#8217;s a great book. The authors use the same humor and dry wit that Python is known for to great effect.  Making the digestion of a very different language easier. I&#8217;m sure that as I continue to experiment with IronPython that I&#8217;ll keep this book close at hand.</p>
<p><iframe src="http://rcm.amazon.com/e/cm?t=lazycoder-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=1933988339&#038;md=10FE9736YVPPT7A0FBG2&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=FFFFFF&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Lazycoder?a=N_WqxCBMsXc:9-TnvAJfFTI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=N_WqxCBMsXc:9-TnvAJfFTI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=N_WqxCBMsXc:9-TnvAJfFTI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=N_WqxCBMsXc:9-TnvAJfFTI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=N_WqxCBMsXc:9-TnvAJfFTI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=N_WqxCBMsXc:9-TnvAJfFTI:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=N_WqxCBMsXc:9-TnvAJfFTI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=N_WqxCBMsXc:9-TnvAJfFTI:F7zBnMyn0Lo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2009/05/28/review-ironpython-in-action/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>7 Habits For Effective Text Editing 2.0</title>
		<link>http://www.lazycoder.com/weblog/2009/05/14/7-habits-for-effective-text-editing-20/</link>
		<comments>http://www.lazycoder.com/weblog/2009/05/14/7-habits-for-effective-text-editing-20/#comments</comments>
		<pubDate>Thu, 14 May 2009 21:18:00 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1125</guid>
		<description><![CDATA[ 
]]></description>
			<content:encoded><![CDATA[<p><embed id="VideoPlayback" src="http://video.google.com/googleplayer.swf?docid=2538831956647446078&#038;hl=en&#038;fs=true" style="width:400px;height:326px" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash"> </embed></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Lazycoder?a=LE1KdXexsJE:es6NuMDnrjM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=LE1KdXexsJE:es6NuMDnrjM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=LE1KdXexsJE:es6NuMDnrjM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=LE1KdXexsJE:es6NuMDnrjM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=LE1KdXexsJE:es6NuMDnrjM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=LE1KdXexsJE:es6NuMDnrjM:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=LE1KdXexsJE:es6NuMDnrjM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=LE1KdXexsJE:es6NuMDnrjM:F7zBnMyn0Lo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2009/05/14/7-habits-for-effective-text-editing-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why these jQuery worst practices aren’t.</title>
		<link>http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/</link>
		<comments>http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/#comments</comments>
		<pubDate>Wed, 13 May 2009 05:34:46 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1121</guid>
		<description><![CDATA[jQuery ... Worst Practices
In this post, Steve Wellens tries to make the case for two common patterns your run across when using jQuery as "worst practices". Practices that are either superfluous or harmful to your code.
1) Wiring up events using unobtrusive JavaScript.
Instead of wiring up your elements events using jQuery, instead you should set the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://weblogs.asp.net/stevewellens/archive/2009/05/09/jquery-three-worst-practices.aspx">jQuery ... Worst Practices</a></p>
<p>In this post, Steve Wellens tries to make the case for two common patterns your run across when using jQuery as "worst practices". Practices that are either superfluous or harmful to your code.</p>
<p>1) Wiring up events using unobtrusive JavaScript.</p>
<p>Instead of wiring up your elements events using jQuery, instead you should set the OnClientClick property of the ASP.NET Web Control in question and call whatever JavaScript you want to handle the event.</p>
<p>Instead of this: </p>
<div class="igBar"><span id="lcode-6"><a href="#" onclick="javascript:showCodeTxt('code-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-6">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script type=<span style="color:#CC0000;">"text/javascript"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color:#006600; font-weight:bold;">&#40;</span>document<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">ready</span><span style="color:#006600; font-weight:bold;">&#40;</span>function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"#Button1"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">click</span><span style="color:#006600; font-weight:bold;">&#40;</span>function<span style="color:#006600; font-weight:bold;">&#40;</span>event<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"You Clicked Me!"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/script&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Do This:</p>
<div class="igBar"><span id="lcode-7"><a href="#" onclick="javascript:showCodeTxt('code-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-7">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;asp:Button ID=<span style="color:#CC0000;">"Button1"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; runat=<span style="color:#CC0000;">"server"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Text=<span style="color:#CC0000;">"MyButton"</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OnClientClick=<span style="color:#CC0000;">"alert('You Clicked Me!');"</span> /&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>His reasoning is as follows:</p>
<blockquote><p>
You might want to change event handlers dynamically depending on some condition in the page.  If you need to assign a common event handler to several objects on a page, it makes sense to do it in one place. As a matter of fact, that's the beauty of jQuery.  But for a single event on a single control….NO.
</p></blockquote>
<p>On can debate whether or not a worst practice can really be applied to a single, specific , one-time event or not. But there are other reasons why you might want to hook up events to a single element using jQuery. one being that you can't hook  up multiple event handlers using OnClientClick or <acronym title='HyperText Markup Language'><span class='caps'>HTML</span></acronym>'s OnClick event, only a single event handler can be assigned. If you are using the observer pattern in your JavaScript, you may have multiple observers that want to subscribe to your buttons click event. But a really strong argument could be made for using the OnClientClick property simply due to ASP.NET's suck-ass way of handling client IDs.</p>
<p>2) Chaining can lead to unreadable code.</p>
<p>In a badly written example, he states that chaining calls to jQuery makes the code unreadable. I'd suggest re-formatting the code in this manner to make it legible and allow for a tighter minimization.</p>
<div class="igBar"><span id="lcode-8"><a href="#" onclick="javascript:showCodeTxt('code-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-8">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"div.highlight"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; .<span style="">css</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"color"</span>, <span style="color:#CC0000;">"yellow"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; .<span style="">css</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"background-color"</span>, <span style="color:#CC0000;">"black"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; .<span style="">css</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"width"</span>, <span style="color:#CC0000;">"50px"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Of course, you wouldn't write jQuery code like that and call the css method multiple times. Ideally, you would just set a class or at the very least <a href="http://docs.jquery.com/<acronym title='Cascading Style Sheets'><span class='caps'>CSS</span></acronym>/css#properties">pass in a set of properties in an object</a>.</p>
<div class="igBar"><span id="lcode-9"><a href="#" onclick="javascript:showCodeTxt('code-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-9">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"div.highlight"</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">css</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; color:<span style="color:#CC0000;">"yellow"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; background-color:<span style="color:#CC0000;">"black"</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; width:<span style="color:#CC0000;">"50px"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>3) Comment your code.</p>
<div class="igBar"><span id="lcode-10"><a href="#" onclick="javascript:showCodeTxt('code-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-10">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// get all the Divs with the highlight class and</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// format them and set their width</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var Divs = $<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"div.highlight"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Divs.<span style="">css</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"color"</span>, <span style="color:#CC0000;">"yellow"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Divs.<span style="">css</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"background-color"</span>, <span style="color:#CC0000;">"black"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Divs.<span style="">css</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"width"</span>, <span style="color:#CC0000;">"30px"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I like this <a href="http://www.codinghorror.com/blog/archives/001150.html">explanation</a> by Jeff Atwood best. If you need comments to explain WHAT your code is doing, you need to use better names and/or write better code. Comments are best when used sparingly and explain the WHY of the code. Why did you choose to use a particular algorithm</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Lazycoder?a=jFlLOyCFgAM:6Am6RPWl6J8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=jFlLOyCFgAM:6Am6RPWl6J8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=jFlLOyCFgAM:6Am6RPWl6J8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=jFlLOyCFgAM:6Am6RPWl6J8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=jFlLOyCFgAM:6Am6RPWl6J8:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=jFlLOyCFgAM:6Am6RPWl6J8:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=jFlLOyCFgAM:6Am6RPWl6J8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=jFlLOyCFgAM:6Am6RPWl6J8:F7zBnMyn0Lo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2009/05/12/why-these-jquery-worst-practices-arent/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC Tip – Return specific views for specific errors.</title>
		<link>http://www.lazycoder.com/weblog/2009/03/18/aspnet-mvc-tip-return-specific-views-for-specific-errors/</link>
		<comments>http://www.lazycoder.com/weblog/2009/03/18/aspnet-mvc-tip-return-specific-views-for-specific-errors/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 15:30:28 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1114</guid>
		<description><![CDATA[Earlier I had said to keep your controllers as thin as possible, that doesn't mean that they should necessarily just be two, or one, lines of code. 
Take an instance where you are retrieving items from a web service in your controller. Let's say that you get a 404 error and your service will throw [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier I had said to keep your controllers as thin as possible, that doesn't mean that they should necessarily just be two, or one, lines of code. </p>
<p>Take an instance where you are retrieving items from a web service in your controller. Let's say that you get a 404 error and your service will throw an exception telling you that the service can't be found.  Take a look at this controller action</p>
<div class="igBar"><span id="lcode-13"><a href="#" onclick="javascript:showCodeTxt('code-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-13">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public ViewResult Item<span style="color:#006600; font-weight:bold;">&#40;</span>string itemID<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Item item = MyWebServiceWrapper.<span style="">GetItem</span><span style="color:#006600; font-weight:bold;">&#40;</span>itemID<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; return View<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"Item"</span>, item<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>As it stands this action is pretty thin, but if an exception is thrown the user will be presented with either whatever custom error page you have defined in your web.config or the dreaded Yellow Screen of Death.(YSOD). You can wrap the call in a try-catch block and catch the exception. But rather than creating a generic errors page that will display any raw exception message, it's a much better idea to return an error specific view to your user with a friendly error message.</p>
<div class="igBar"><span id="lcode-14"><a href="#" onclick="javascript:showCodeTxt('code-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-14">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public ViewResult Item<span style="color:#006600; font-weight:bold;">&#40;</span>string itemID<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; try</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Item item = MyWebServiceWrapper.<span style="">GetItem</span><span style="color:#006600; font-weight:bold;">&#40;</span>itemID<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; return View<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"Item"</span>, item<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; catch<span style="color:#006600; font-weight:bold;">&#40;</span>ServiceCannotBeReachedException<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Item item = new Item<span style="color:#006600; font-weight:bold;">&#40;</span>itemID<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; return View<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"CannotRetrieveItem"</span>, item<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//The CannotReachService view has a line that looks like this</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// &quot;The item &lt;%= Model.itemID %&gt; can not be retrieved at this time. Please try again later&quot;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// obviously this can be globalized/localized as needed. </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This leads to a much "dumber" view and is a much better idea than modifying the "Item" view to display errors if something isn't right with the model or passing in special error parameters to the view. Let the view deal with the data it is meant to display and nothing else.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Lazycoder?a=G7Gz32PbfoU:5U6BBHzgKp0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=G7Gz32PbfoU:5U6BBHzgKp0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=G7Gz32PbfoU:5U6BBHzgKp0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=G7Gz32PbfoU:5U6BBHzgKp0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=G7Gz32PbfoU:5U6BBHzgKp0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=G7Gz32PbfoU:5U6BBHzgKp0:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=G7Gz32PbfoU:5U6BBHzgKp0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=G7Gz32PbfoU:5U6BBHzgKp0:F7zBnMyn0Lo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2009/03/18/aspnet-mvc-tip-return-specific-views-for-specific-errors/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC tip – Don’t use the Content or Scripts directories for view specific files</title>
		<link>http://www.lazycoder.com/weblog/2009/03/17/aspnet-mvc-tip-dont-use-the-content-or-scripts-directories-for-view-specific-files/</link>
		<comments>http://www.lazycoder.com/weblog/2009/03/17/aspnet-mvc-tip-dont-use-the-content-or-scripts-directories-for-view-specific-files/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 15:39:31 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1112</guid>
		<description><![CDATA[ASP.NET MVC creates a default file structure for you when you create a new project. It includes a Scripts directory, which contains the MS AJAX and jQuery .js files, and a content directory, which contains a Master page and CSS files. I find this to be extremely cumbersome and it forces me to jump around [...]]]></description>
			<content:encoded><![CDATA[<p>ASP.NET MVC creates a default file structure for you when you create a new project. It includes a Scripts directory, which contains the MS <acronym title='Asynchronous Javascript and XML'><span class='caps'>AJAX</span></acronym> and jQuery .js files, and a content directory, which contains a Master page and <acronym title='Cascading Style Sheets'><span class='caps'>CSS</span></acronym> files. I find this to be extremely cumbersome and it forces me to jump around a lot. Storing shared <acronym title='Cascading Style Sheets'><span class='caps'>CSS</span></acronym> and JavaScript files in those locations is fine in my opinion. But if you are using View specific <acronym title='Cascading Style Sheets'><span class='caps'>CSS</span></acronym> or JavaScript files, you should put them alongside your view page in the Views directory. This allows you to quickly find the file you want to work on.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Lazycoder?a=mn4Jpl3SDm8:iv6gBJ_IcvA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=mn4Jpl3SDm8:iv6gBJ_IcvA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=mn4Jpl3SDm8:iv6gBJ_IcvA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=mn4Jpl3SDm8:iv6gBJ_IcvA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=mn4Jpl3SDm8:iv6gBJ_IcvA:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=mn4Jpl3SDm8:iv6gBJ_IcvA:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=mn4Jpl3SDm8:iv6gBJ_IcvA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=mn4Jpl3SDm8:iv6gBJ_IcvA:F7zBnMyn0Lo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2009/03/17/aspnet-mvc-tip-dont-use-the-content-or-scripts-directories-for-view-specific-files/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC TIP – Keep your controllers and actions thin</title>
		<link>http://www.lazycoder.com/weblog/2009/03/16/aspnet-mvc-tip-keep-your-controllers-and-actions-thin/</link>
		<comments>http://www.lazycoder.com/weblog/2009/03/16/aspnet-mvc-tip-keep-your-controllers-and-actions-thin/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 15:16:03 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.lazycoder.com/weblog/?p=1110</guid>
		<description><![CDATA[When writing you controller actions, keep them short and sweet. Don't add a lot of actions and keep a close eye on the length of each action.
Whenever possible, I try to make my controller actions look something like this.
PLAIN TEXT
CODE:




public ActionResult DoSomething&#40;&#41;


&#123;


&#160; &#160; MyModel model = MyService.GetModel&#40;&#41;;


&#160; &#160; return View&#40;"MyView",model&#41;;


&#125;


//or


public ActionResult DoSomethingWithAKey&#40;int myKey&#41;


&#123;


&#160; &#160; MyModel [...]]]></description>
			<content:encoded><![CDATA[<p>When writing you controller actions, keep them short and sweet. Don't add a lot of actions and keep a close eye on the length of each action.<br />
Whenever possible, I try to make my controller actions look something like this.</p>
<div class="igBar"><span id="lcode-16"><a href="#" onclick="javascript:showCodeTxt('code-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-16">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public ActionResult DoSomething<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; MyModel model = MyService.<span style="">GetModel</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; return View<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"MyView"</span>,model<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//or</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public ActionResult DoSomethingWithAKey<span style="color:#006600; font-weight:bold;">&#40;</span>int myKey<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; MyModel model = MyService.<span style="">GetModel</span><span style="color:#006600; font-weight:bold;">&#40;</span>myKey<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; return View<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"MyView"</span>,model<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p> <em>(1)</em></p>
<p>There are two reasons to do this:</p>
<p>1) It makes your controllers less complicated and easier to maintain. - You don't want to have to do a lot of debugging in your controllers. Chances are, if you have a lot of complicated logic in your controller actions, you are probably mixing concerns. Make sure that your controllers are only responsible for getting data from your models and figuring out what view to send to the client.</p>
<p>2) It makes testing easier. If all you are doing is getting a model and passing that model to a view, what do you really need to test? Maybe that the correct view is being returned.</p>
<p><em>(1)</em> Of course I use more descriptive names than "myKey". <img src='http://www.lazycoder.com/weblog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Lazycoder?a=mgcspTmoYHA:bh3n9pEOz-A:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=mgcspTmoYHA:bh3n9pEOz-A:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=mgcspTmoYHA:bh3n9pEOz-A:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=mgcspTmoYHA:bh3n9pEOz-A:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=mgcspTmoYHA:bh3n9pEOz-A:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=mgcspTmoYHA:bh3n9pEOz-A:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Lazycoder?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Lazycoder?a=mgcspTmoYHA:bh3n9pEOz-A:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Lazycoder?i=mgcspTmoYHA:bh3n9pEOz-A:F7zBnMyn0Lo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.lazycoder.com/weblog/2009/03/16/aspnet-mvc-tip-keep-your-controllers-and-actions-thin/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
