<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Wrap Your NameValue Variables</title>
	<atom:link href="http://www.sitepoint.com/blogs/2007/02/25/wrap-your-namevalue-variables/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2007/02/25/wrap-your-namevalue-variables/</link>
	<description></description>
	<pubDate>Sat, 30 Aug 2008 11:21:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: TheDeathart</title>
		<link>http://www.sitepoint.com/blogs/2007/02/25/wrap-your-namevalue-variables/#comment-198205</link>
		<dc:creator>TheDeathart</dc:creator>
		<pubDate>Fri, 09 Mar 2007 08:30:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1860#comment-198205</guid>
		<description>wow.. you wrote a singleton serializing to a session......</description>
		<content:encoded><![CDATA[<p>wow.. you wrote a singleton serializing to a session&#8230;&#8230;</p>]]></content:encoded>
	</item>
	<item>
		<title>By: yacka</title>
		<link>http://www.sitepoint.com/blogs/2007/02/25/wrap-your-namevalue-variables/#comment-188875</link>
		<dc:creator>yacka</dc:creator>
		<pubDate>Sun, 25 Feb 2007 20:00:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1860#comment-188875</guid>
		<description>Wyatt,

That's a fair point, but I thought you were trying to guarantee you had the correct type.</description>
		<content:encoded><![CDATA[<p>Wyatt,</p>
<p>That&#8217;s a fair point, but I thought you were trying to guarantee you had the correct type.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: yacka</title>
		<link>http://www.sitepoint.com/blogs/2007/02/25/wrap-your-namevalue-variables/#comment-188872</link>
		<dc:creator>yacka</dc:creator>
		<pubDate>Sun, 25 Feb 2007 19:55:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1860#comment-188872</guid>
		<description>dhtmlgod,

I know. I was re-emphasizing his point because it was confused with all the other stuff.  The issues he describes are not addressed by removing code into a base class, it's merely a different way of writing the same thing.</description>
		<content:encoded><![CDATA[<p>dhtmlgod,</p>
<p>I know. I was re-emphasizing his point because it was confused with all the other stuff.  The issues he describes are not addressed by removing code into a base class, it&#8217;s merely a different way of writing the same thing.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: dhtmlgod</title>
		<link>http://www.sitepoint.com/blogs/2007/02/25/wrap-your-namevalue-variables/#comment-188823</link>
		<dc:creator>dhtmlgod</dc:creator>
		<pubDate>Sun, 25 Feb 2007 18:03:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1860#comment-188823</guid>
		<description>&lt;blockquote&gt;However none of this addresses what I think is your most important point, removing the redundancy of code. We could include the above code in each page where we need to access the cart, but that would create unnecessary maintenance overhead because we would need to update every instance of the code if anything changed.&lt;/blockquote&gt;Not if you do what Wyatt suggested and have it in a base page class and inherit from that.</description>
		<content:encoded><![CDATA[<blockquote><p>However none of this addresses what I think is your most important point, removing the redundancy of code. We could include the above code in each page where we need to access the cart, but that would create unnecessary maintenance overhead because we would need to update every instance of the code if anything changed.</p></blockquote>
<p>Not if you do what Wyatt suggested and have it in a base page class and inherit from that.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: wwb_99</title>
		<link>http://www.sitepoint.com/blogs/2007/02/25/wrap-your-namevalue-variables/#comment-188749</link>
		<dc:creator>wwb_99</dc:creator>
		<pubDate>Sun, 25 Feb 2007 14:21:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1860#comment-188749</guid>
		<description>@yacka: good points. The slightly different property wrapping is very good, but I like mine because, if I (or some other dev) was dumb enough to use the wrong name, something would blow up somewhere, whereas your approach would very effectively silently eat errors.

@anon: Yes, it is a garden variety application layer error. But to end users, the server catching on fire and "there was an issue accessing the page" are the same thing and best avoided and/or caught during development.</description>
		<content:encoded><![CDATA[<p>@yacka: good points. The slightly different property wrapping is very good, but I like mine because, if I (or some other dev) was dumb enough to use the wrong name, something would blow up somewhere, whereas your approach would very effectively silently eat errors.</p>
<p>@anon: Yes, it is a garden variety application layer error. But to end users, the server catching on fire and &#8220;there was an issue accessing the page&#8221; are the same thing and best avoided and/or caught during development.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.sitepoint.com/blogs/2007/02/25/wrap-your-namevalue-variables/#comment-188407</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Sun, 25 Feb 2007 03:08:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1860#comment-188407</guid>
		<description>&#62; Crashes mean application layer errors, not system-wide halts.

well, thats not a crash then; its just your common garden error. a crash is something that brings the server down... nasty no?

where do you .net developers get your terminology from? m$? god? 

the doctor</description>
		<content:encoded><![CDATA[<p>&gt; Crashes mean application layer errors, not system-wide halts.</p>
<p>well, thats not a crash then; its just your common garden error. a crash is something that brings the server down&#8230; nasty no?</p>
<p>where do you .net developers get your terminology from? m$? god? </p>
<p>the doctor</p>]]></content:encoded>
	</item>
	<item>
		<title>By: yacka</title>
		<link>http://www.sitepoint.com/blogs/2007/02/25/wrap-your-namevalue-variables/#comment-188268</link>
		<dc:creator>yacka</dc:creator>
		<pubDate>Sat, 24 Feb 2007 22:00:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1860#comment-188268</guid>
		<description>What you're saying is essentially good, but you've weakened the message by addressing two different issues, the loose typing of session and redundancy of code.  

As far as loose typing is concerned, I don't see how your second example really improves on the first. You're still assuming that the 'ShoppingCart' will be the correct type.  An exception will occur if for some reason an object has been stored in the session using the same key.  The code you've written is essentially the same, even if the latter has been separated to a base class and exposes the cart via a property.

Perhaps a better example would be:

&lt;pre&gt;&lt;code class="html"&gt;
protected ShoppingCart Cart  
{  
   get  
   {
       ShoppingCart myCart = Session["ShoppingCart"] as ShoppingCart();
	
       if(myCart == null)  
       {  
           myCart = new ShoppingCart();

	   Session["ShoppingCart"] = myCart;
       }

       return myCart;
    }  
} 
&lt;/code&gt;&lt;/pre&gt;

This approach will always return a valid shopping cart without an exception, even if elsewhere 'ShoppingCart' has been used in the session for differently typed object.  It's a defensive approach that protects you against the unforseen and the loose typing of session.

However none of this addresses what I think is your most important point, removing the redundancy of code.  We could include the above code in each page where we need to access the cart, but that would create unnecessary maintenance overhead because we would need to update every instance of the code if anything changed.

If you find you're repeating code, find some way of isolating that code so it can be reused directly in all required circumstances.  As you suggest, moving the code to a base class would be one method of achieving that.</description>
		<content:encoded><![CDATA[<p>What you&#8217;re saying is essentially good, but you&#8217;ve weakened the message by addressing two different issues, the loose typing of session and redundancy of code.  </p>
<p>As far as loose typing is concerned, I don&#8217;t see how your second example really improves on the first. You&#8217;re still assuming that the &#8216;ShoppingCart&#8217; will be the correct type.  An exception will occur if for some reason an object has been stored in the session using the same key.  The code you&#8217;ve written is essentially the same, even if the latter has been separated to a base class and exposes the cart via a property.</p>
<p>Perhaps a better example would be:</p>
<pre><code class="html">
protected ShoppingCart Cart  
{  
   get  
   {
       ShoppingCart myCart = Session["ShoppingCart"] as ShoppingCart();
	
       if(myCart == null)  
       {  
           myCart = new ShoppingCart();

	   Session["ShoppingCart"] = myCart;
       }

       return myCart;
    }  
} 
</code></pre>
<p>This approach will always return a valid shopping cart without an exception, even if elsewhere &#8216;ShoppingCart&#8217; has been used in the session for differently typed object.  It&#8217;s a defensive approach that protects you against the unforseen and the loose typing of session.</p>
<p>However none of this addresses what I think is your most important point, removing the redundancy of code.  We could include the above code in each page where we need to access the cart, but that would create unnecessary maintenance overhead because we would need to update every instance of the code if anything changed.</p>
<p>If you find you&#8217;re repeating code, find some way of isolating that code so it can be reused directly in all required circumstances.  As you suggest, moving the code to a base class would be one method of achieving that.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: wwb_99</title>
		<link>http://www.sitepoint.com/blogs/2007/02/25/wrap-your-namevalue-variables/#comment-188200</link>
		<dc:creator>wwb_99</dc:creator>
		<pubDate>Sat, 24 Feb 2007 19:46:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1860#comment-188200</guid>
		<description>Crashes mean application layer errors, not system-wide halts. You know, the kind of errors one gets all the time in loosely typed frameworks if one is not ultra careful about passing the right objects around to the right methods.</description>
		<content:encoded><![CDATA[<p>Crashes mean application layer errors, not system-wide halts. You know, the kind of errors one gets all the time in loosely typed frameworks if one is not ultra careful about passing the right objects around to the right methods.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.sitepoint.com/blogs/2007/02/25/wrap-your-namevalue-variables/#comment-188197</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Sat, 24 Feb 2007 19:41:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1860#comment-188197</guid>
		<description>off topic but,

&#62; Errors can lead to crashes at best,

what do you mean by a crash though? how severe is it? the framework in question must be pretty fragile no; i mean a lack of encapsulation could cause so much damage?

i'm not having a go (well, just a wee bit, but thats not the point) but maybe you could enlighten us lot who develop without this 'state of the art' framework from m$

best regards, the doctor.</description>
		<content:encoded><![CDATA[<p>off topic but,</p>
<p>&gt; Errors can lead to crashes at best,</p>
<p>what do you mean by a crash though? how severe is it? the framework in question must be pretty fragile no; i mean a lack of encapsulation could cause so much damage?</p>
<p>i&#8217;m not having a go (well, just a wee bit, but thats not the point) but maybe you could enlighten us lot who develop without this &#8217;state of the art&#8217; framework from m$</p>
<p>best regards, the doctor.</p>]]></content:encoded>
	</item>
</channel>
</rss>
