<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Fields and virtual members</title>
	<atom:link href="http://lostechies.com/jimmybogard/2009/11/09/fields-and-virtual-members/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/jimmybogard/2009/11/09/fields-and-virtual-members/</link>
	<description>Strong opinions, weakly held</description>
	<lastBuildDate>Sat, 25 May 2013 16:53:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Dan Puzey</title>
		<link>http://lostechies.com/jimmybogard/2009/11/09/fields-and-virtual-members/#comment-1989</link>
		<dc:creator>Dan Puzey</dc:creator>
		<pubDate>Mon, 16 Nov 2009 19:15:54 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/11/09/fields-and-virtual-members.aspx#comment-1989</guid>
		<description>While I agree that you shouldn&#039;t have &quot;behaviour&quot; in a property, it&#039;s not difficult to think of cases where you need logic in a property: I&#039;d expect most setters to have some basic validation in them - checking for null, or negative numbers or whatever.  That typically requires a backing field, unless there&#039;s some syntax I haven&#039;t learnt yet (which is entirely possible :-))</description>
		<content:encoded><![CDATA[<p>While I agree that you shouldn&#8217;t have &#8220;behaviour&#8221; in a property, it&#8217;s not difficult to think of cases where you need logic in a property: I&#8217;d expect most setters to have some basic validation in them &#8211; checking for null, or negative numbers or whatever.  That typically requires a backing field, unless there&#8217;s some syntax I haven&#8217;t learnt yet (which is entirely possible <img src='http://lostechies.com/jimmybogard/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahesh</title>
		<link>http://lostechies.com/jimmybogard/2009/11/09/fields-and-virtual-members/#comment-1988</link>
		<dc:creator>Mahesh</dc:creator>
		<pubDate>Fri, 13 Nov 2009 14:50:13 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/11/09/fields-and-virtual-members.aspx#comment-1988</guid>
		<description>Since property is converted into method in IL, there could be slight performance hit as it is method call.
</description>
		<content:encoded><![CDATA[<p>Since property is converted into method in IL, there could be slight performance hit as it is method call.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2009/11/09/fields-and-virtual-members/#comment-1987</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Wed, 11 Nov 2009 13:10:35 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/11/09/fields-and-virtual-members.aspx#comment-1987</guid>
		<description>@Ryan

Do you mean manual lazy loading?  I haven&#039;t done that kind of code in a long, long time.</description>
		<content:encoded><![CDATA[<p>@Ryan</p>
<p>Do you mean manual lazy loading?  I haven&#8217;t done that kind of code in a long, long time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan R</title>
		<link>http://lostechies.com/jimmybogard/2009/11/09/fields-and-virtual-members/#comment-1986</link>
		<dc:creator>Ryan R</dc:creator>
		<pubDate>Tue, 10 Nov 2009 20:55:37 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/11/09/fields-and-virtual-members.aspx#comment-1986</guid>
		<description>How about lazy loading? I have yet to see a good way (no reflection) of lazy loading an automatic property.</description>
		<content:encoded><![CDATA[<p>How about lazy loading? I have yet to see a good way (no reflection) of lazy loading an automatic property.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fizz</title>
		<link>http://lostechies.com/jimmybogard/2009/11/09/fields-and-virtual-members/#comment-1985</link>
		<dc:creator>Fizz</dc:creator>
		<pubDate>Tue, 10 Nov 2009 09:38:53 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/11/09/fields-and-virtual-members.aspx#comment-1985</guid>
		<description>I want Property scoped values, solves all of these problems

public int MyProperty
{
    int myField;
   get { return myField; }
   set
   {
        if (!MyFieldValid(value) throw new Exception(&quot;&quot;);
        myField = value;
        NotifyPropertyChanged(&quot;MyProperty&quot;);
    }
}

MS does not think this is usefull</description>
		<content:encoded><![CDATA[<p>I want Property scoped values, solves all of these problems</p>
<p>public int MyProperty<br />
{<br />
    int myField;<br />
   get { return myField; }<br />
   set<br />
   {<br />
        if (!MyFieldValid(value) throw new Exception(&#8220;&#8221;);<br />
        myField = value;<br />
        NotifyPropertyChanged(&#8220;MyProperty&#8221;);<br />
    }<br />
}</p>
<p>MS does not think this is usefull</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Artem Govorov</title>
		<link>http://lostechies.com/jimmybogard/2009/11/09/fields-and-virtual-members/#comment-1984</link>
		<dc:creator>Artem Govorov</dc:creator>
		<pubDate>Tue, 10 Nov 2009 05:24:54 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/11/09/fields-and-virtual-members.aspx#comment-1984</guid>
		<description>Presentation frameworks (WinForms, WPF) UI elements 2-way data binding heavily depends on read/write properties and INotifyPropertyChanged interface implementation, so property setter is an obvious place to put code raising property changed event. I&#039;m not saying that this is good or bad - it just the way it is and this makes it impossible to use auto properties in these cases.</description>
		<content:encoded><![CDATA[<p>Presentation frameworks (WinForms, WPF) UI elements 2-way data binding heavily depends on read/write properties and INotifyPropertyChanged interface implementation, so property setter is an obvious place to put code raising property changed event. I&#8217;m not saying that this is good or bad &#8211; it just the way it is and this makes it impossible to use auto properties in these cases.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AlexEzh</title>
		<link>http://lostechies.com/jimmybogard/2009/11/09/fields-and-virtual-members/#comment-1983</link>
		<dc:creator>AlexEzh</dc:creator>
		<pubDate>Mon, 09 Nov 2009 22:29:23 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/11/09/fields-and-virtual-members.aspx#comment-1983</guid>
		<description>I would say differently. It is fine to use fields in the class implementation and expose property accessors as long as accessors are not virtual. If virtual accessor is required, than ideally it should be abstract to avoid unnecessary fields in the class implementation.</description>
		<content:encoded><![CDATA[<p>I would say differently. It is fine to use fields in the class implementation and expose property accessors as long as accessors are not virtual. If virtual accessor is required, than ideally it should be abstract to avoid unnecessary fields in the class implementation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2009/11/09/fields-and-virtual-members/#comment-1982</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Mon, 09 Nov 2009 20:57:39 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/11/09/fields-and-virtual-members.aspx#comment-1982</guid>
		<description>@Paco et al

LSP isn&#039;t violated here.  Fields are an implementation detail and should never be exposed outside of that class (i.e., instance fields should always be private).

It&#039;s just one of those cases where if a class exposes state, it should be self-consistent and use the property accessors.</description>
		<content:encoded><![CDATA[<p>@Paco et al</p>
<p>LSP isn&#8217;t violated here.  Fields are an implementation detail and should never be exposed outside of that class (i.e., instance fields should always be private).</p>
<p>It&#8217;s just one of those cases where if a class exposes state, it should be self-consistent and use the property accessors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christopher Harris</title>
		<link>http://lostechies.com/jimmybogard/2009/11/09/fields-and-virtual-members/#comment-1981</link>
		<dc:creator>Christopher Harris</dc:creator>
		<pubDate>Mon, 09 Nov 2009 20:48:30 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/11/09/fields-and-virtual-members.aspx#comment-1981</guid>
		<description>@Paco: I have to admit you make a very interesting observation on breaking the LSP.  It makes me wonder if this is one of those cases where a new trivial unit test would have been more appropriate to catch the CompareTo bug. (Clean Code: Smell T3: Don&#039;t Skip Trivial Tests)</description>
		<content:encoded><![CDATA[<p>@Paco: I have to admit you make a very interesting observation on breaking the LSP.  It makes me wonder if this is one of those cases where a new trivial unit test would have been more appropriate to catch the CompareTo bug. (Clean Code: Smell T3: Don&#8217;t Skip Trivial Tests)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AlexEzh</title>
		<link>http://lostechies.com/jimmybogard/2009/11/09/fields-and-virtual-members/#comment-1980</link>
		<dc:creator>AlexEzh</dc:creator>
		<pubDate>Mon, 09 Nov 2009 20:38:34 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/11/09/fields-and-virtual-members.aspx#comment-1980</guid>
		<description>Why not set _value to 5 which would keep the existing class logic? I understand that the class is an example, but you are trying to hide the behavior of the base class which is a violation of Liskov substitution principle. Article on Wikipedia has a good example.</description>
		<content:encoded><![CDATA[<p>Why not set _value to 5 which would keep the existing class logic? I understand that the class is an example, but you are trying to hide the behavior of the base class which is a violation of Liskov substitution principle. Article on Wikipedia has a good example.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
