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

<channel>
	<title>Meadows Design &#187; Coding Smarter</title>
	<atom:link href="http://meadowsdesign.com/blog/category/development/coding-smarter/feed/" rel="self" type="application/rss+xml" />
	<link>http://meadowsdesign.com/blog</link>
	<description>News, Notes and Nothings from a Custom Solution Provider</description>
	<lastBuildDate>Sat, 29 Aug 2009 13:22:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Coding Smarter &#8211; Understand Your Medium</title>
		<link>http://meadowsdesign.com/blog/2009/08/12/code-smarter-understand-your-medium/</link>
		<comments>http://meadowsdesign.com/blog/2009/08/12/code-smarter-understand-your-medium/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 18:05:54 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Coding Smarter]]></category>

		<guid isPermaLink="false">http://meadowsdesign.com/blog/?p=46</guid>
		<description><![CDATA[There has been a lot of chatter lately about good design practices.  I don&#8217;t know if this is because I&#8217;ve just noticed it more, if it&#8217;s part of the alt.net push on the community, or if there are actually more people interested in improving our craft.  
Several sites exist out there that urge [...]]]></description>
			<content:encoded><![CDATA[<p>There has been a lot of chatter lately about good design practices.  I don&#8217;t know if this is because I&#8217;ve just noticed it more, if it&#8217;s part of the alt.net push on the community, or if there are actually more people interested in improving our craft.  </p>
<p>Several sites exist out there that urge developers to think about what they&#8217;re doing and they range from the architectural perspective (<a href="http://www.codebetter.com">codebetter.com</a>) to the human factors perspective (<a href="http://www.codinghorror.com">codinghorror.com</a> &#8212; an excellent site that never disappoints.)</p>
<p>Regardless of the reason, it appears to me that a fundamental piece of the puzzle is missing.  That piece being coding better isn&#8217;t the same thing as coding smarter.  It appears to me that some developers have a unique form of <a href="http://en.wikipedia.org/wiki/Savant_syndrome">savant syndrome</a> granting them all the architectural prowess for which one could ever hope but none of the common sense development practices that can actually make or break an application.</p>
<div align="center"><img src="/blog/images/rainman.jpg" alt="I'm an excellent developer." /><br />
I&#8217;m an excellent developer.<br />&nbsp;
</div>
<p>Let&#8217;s take the following scenario that, sadly, is one of four from an application I inherited.</p>
<p>The first scenario in &#8220;Coding Smarter&#8221; involves understanding your medium.  By that, I mean that you should really understand how the technology you&#8217;re using functions.  </p>
<p>This application wanted to maintain a user id once the user was logged in.  I wrote about an <a href="http://stackoverflow.com/questions/1263580/persisting-caching-data-between-requests-common-approach/1264062">expansion of this method on Stackoverflow</a>.  </p>
<p>The general idea is that you want to maintain as little (or as much, sadly) state as you can between requests and given that <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">HTTP is a stateless protocol</a> you need to store it somewhere.  Typically this information is stored in the session on the server but the authors of the application didn&#8217;t deem the session worthy and decided that they would store the user id of the user making the request in&#8230; wait for it&#8230; the ViewState.</p>
<div align="center">
<img src="/blog/images/facepalm.jpg" alt="Facepalm - because expressing how dumb this is in words is impossible." /><br />&nbsp;
</div>
<p>Think about this for a second.  What do we know about the ViewState?</p>
<p>Well, for starters, the ViewState is sent back and forth between the server and the client.  This means that for every item that is stored in the ViewState, that item must be <a href="http://msdn.microsoft.com/en-us/library/ms972976.aspx#viewstate_topic8">returned from the client to the server with every request</a>. (Incidentally, they also made liberal use of UpdatePanel).  This might be &#8220;OK&#8221; &#8212; not really, but wait for it &#8212; because the user id is only an integer, but this application stored EVERYTHING in the ViewState that it needed.  No use of session variables were involved.  </p>
<p>The BIGGER issue with storing the user id in the ViewState is that it is not secure.  ViewState is not encrypted by default, <a href="http://msdn.microsoft.com/en-us/library/ms972976.aspx#viewstate_topic12">merely encoded</a>.  Not surprisingly, there was no encrypting of the ViewState taking place in the code so anyone that could access it could decode it.  </p>
<p>In the developer&#8217;s defense, they did encrypt the individual fields that were going into the ViewState, but unless they were <a href="http://www.codeproject.com/KB/security/SimpleEncryption.aspx">encrypting them properly</a> they may as well not have encrypted them at all.</p>
<p>The BIGGEST problem is that there is, essentially, no user  authentication timeout.  That means that the user can be using the site, step away from the computer for a week, a month, even a year, and then come back and continue on their merry way on the site.  Or, go about browsing other sites, hit back in their browser to load a page from the site (there was also no client-side cache expiration), perform some new action and automatically be logged into the site.  This <em>might</em> be fine on a site that&#8217;s not handling sensitive information.  Unfortunately, this site is.</p>
<p>The lesson is that just because a framework or platform makes something available to you doesn&#8217;t mean that you have to use it.  If you want to use it, make sure you understand what it is, how it functions, and what the repercussions of using it actually are.</p>
<p>I&#8217;m debating on turning this into a series given the number of issues I typically stumble upon when inheriting projects.  If you would like to see more of this, let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://meadowsdesign.com/blog/2009/08/12/code-smarter-understand-your-medium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
