<?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: Trends: Getters and Setters, going the way of the dinosaur?</title>
	<atom:link href="http://www.turnleafdesign.com/trends-getters-and-setters-going-the-way-of-the-dinosaur/feed" rel="self" type="application/rss+xml" />
	<link>http://www.turnleafdesign.com/trends-getters-and-setters-going-the-way-of-the-dinosaur</link>
	<description>Ramblings of a junior developer</description>
	<lastBuildDate>Thu, 20 Jan 2011 09:21:13 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: 6 traits of successful developers &#124; Turnleaf Design</title>
		<link>http://www.turnleafdesign.com/trends-getters-and-setters-going-the-way-of-the-dinosaur/comment-page-1#comment-485</link>
		<dc:creator>6 traits of successful developers &#124; Turnleaf Design</dc:creator>
		<pubDate>Thu, 16 Sep 2010 04:40:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.turnleafdesign.com/?p=101#comment-485</guid>
		<description>[...] mentor and that is ensuring the knowledge being passed on is good. I have taken this responsibility for granted in the past, at the time I didn&#039;t understand the importance of getters and setters and I irresponsibly [...]</description>
		<content:encoded><![CDATA[<p>[...] mentor and that is ensuring the knowledge being passed on is good. I have taken this responsibility for granted in the past, at the time I didn&#039;t understand the importance of getters and setters and I irresponsibly [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Gorman</title>
		<link>http://www.turnleafdesign.com/trends-getters-and-setters-going-the-way-of-the-dinosaur/comment-page-1#comment-408</link>
		<dc:creator>Jason Gorman</dc:creator>
		<pubDate>Thu, 12 Nov 2009 19:56:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.turnleafdesign.com/?p=101#comment-408</guid>
		<description>I think there&#039;s a danger here of folk blindly applying a design rule (&quot;don&#039;t use getters and setters&quot;) without applying any thought as to the reasons why.

The less objects know about each other, and the more data and associated behaviour can be internalised within objects, the less coupling there&#039;ll be between objects and therefore the easier it will be to make a change to one class without impacting on other classes.

&quot;Don&#039;t use getters and setters&quot; is no more a design insight than &quot;singletons are bad&quot; or &quot;use dependency injection&quot;.

Objects have to share data. Otherwise you would have to put everything in one class. The goal is to minimise the amount of sharing and maximise the internal cohesion of classes. Not to do away with accessor methods.</description>
		<content:encoded><![CDATA[<p>I think there&#8217;s a danger here of folk blindly applying a design rule (&#8220;don&#8217;t use getters and setters&#8221;) without applying any thought as to the reasons why.</p>
<p>The less objects know about each other, and the more data and associated behaviour can be internalised within objects, the less coupling there&#8217;ll be between objects and therefore the easier it will be to make a change to one class without impacting on other classes.</p>
<p>&#8220;Don&#8217;t use getters and setters&#8221; is no more a design insight than &#8220;singletons are bad&#8221; or &#8220;use dependency injection&#8221;.</p>
<p>Objects have to share data. Otherwise you would have to put everything in one class. The goal is to minimise the amount of sharing and maximise the internal cohesion of classes. Not to do away with accessor methods.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith Braithwaite</title>
		<link>http://www.turnleafdesign.com/trends-getters-and-setters-going-the-way-of-the-dinosaur/comment-page-1#comment-407</link>
		<dc:creator>Keith Braithwaite</dc:creator>
		<pubDate>Thu, 12 Nov 2009 16:21:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.turnleafdesign.com/?p=101#comment-407</guid>
		<description>building object-oriented software without the use of getters (and setters) was one of the drivers behind what we now know as Mock Objects. See http://peripateticaxiom.blogspot.com/2008/06/tdd-mocks-and-design.html for a discussion.

The more general case is to &quot;tell, don&#039;t ask&quot; and not enquire about the properties of objects at all.</description>
		<content:encoded><![CDATA[<p>building object-oriented software without the use of getters (and setters) was one of the drivers behind what we now know as Mock Objects. See <a href="http://peripateticaxiom.blogspot.com/2008/06/tdd-mocks-and-design.html" rel="nofollow">http://peripateticaxiom.blogspot.com/2008/06/tdd-mocks-and-design.html</a> for a discussion.</p>
<p>The more general case is to &#8220;tell, don&#8217;t ask&#8221; and not enquire about the properties of objects at all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Normand</title>
		<link>http://www.turnleafdesign.com/trends-getters-and-setters-going-the-way-of-the-dinosaur/comment-page-1#comment-406</link>
		<dc:creator>Eric Normand</dc:creator>
		<pubDate>Thu, 12 Nov 2009 16:21:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.turnleafdesign.com/?p=101#comment-406</guid>
		<description>I was taught to do getters and setters in Java for one reason:

Implementation hiding

It might look like a field of a class is only there to hold a value, but down the road, you might want to add validation to the setter or a different type of getter (calculated from another value or retrieved from a database).</description>
		<content:encoded><![CDATA[<p>I was taught to do getters and setters in Java for one reason:</p>
<p>Implementation hiding</p>
<p>It might look like a field of a class is only there to hold a value, but down the road, you might want to add validation to the setter or a different type of getter (calculated from another value or retrieved from a database).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://www.turnleafdesign.com/trends-getters-and-setters-going-the-way-of-the-dinosaur/comment-page-1#comment-405</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Thu, 12 Nov 2009 15:46:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.turnleafdesign.com/?p=101#comment-405</guid>
		<description>Surely they are useful in case you ever need to change the simple member access to something more complex. As others have already said exposing the member variables directly is dangerous. What if you ever needed to do validation before storing the value?</description>
		<content:encoded><![CDATA[<p>Surely they are useful in case you ever need to change the simple member access to something more complex. As others have already said exposing the member variables directly is dangerous. What if you ever needed to do validation before storing the value?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Developer Dude</title>
		<link>http://www.turnleafdesign.com/trends-getters-and-setters-going-the-way-of-the-dinosaur/comment-page-1#comment-314</link>
		<dc:creator>Developer Dude</dc:creator>
		<pubDate>Thu, 22 Oct 2009 16:48:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.turnleafdesign.com/?p=101#comment-314</guid>
		<description>Still, it will be nice when Java supports UAP - there was some talk of supporting &#039;properties&#039; (like C# does) in JDK 7, but I don&#039;t think that will happen this time around. Of all of the changes in JDK 7, I would have preferred &#039;properties&#039; support and improved null syntax/handling to be towards the top of the list.

Many IDEs will generate your getters/setters for you.</description>
		<content:encoded><![CDATA[<p>Still, it will be nice when Java supports UAP &#8211; there was some talk of supporting &#8216;properties&#8217; (like C# does) in JDK 7, but I don&#8217;t think that will happen this time around. Of all of the changes in JDK 7, I would have preferred &#8216;properties&#8217; support and improved null syntax/handling to be towards the top of the list.</p>
<p>Many IDEs will generate your getters/setters for you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Developer Dude</title>
		<link>http://www.turnleafdesign.com/trends-getters-and-setters-going-the-way-of-the-dinosaur/comment-page-1#comment-313</link>
		<dc:creator>Developer Dude</dc:creator>
		<pubDate>Thu, 22 Oct 2009 16:16:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.turnleafdesign.com/?p=101#comment-313</guid>
		<description>For simple immutable value objects (in Java) that are nothing but containers for the attributes, then I have recently begun exposing the property directly by making it public. But that requires the values be passed in via the constructor or retrieved there, or made with a helper (which seems like a lot of trouble and adds extra maintenance and logic that can have bugs in it). So when there are more than a few properties that kind of falls flat on its face - who wants a constructor with 20 arguments? I use these &#039;public&#039; immutables for simple tuples of arguments that need to be grouped together when there are less than say 5 or so properties.

But what do getters/setters hide? Sometimes they hide validation. Sometimes they hide construction or retrieval of the property from somewhere else. Sometimes they hide a calculation. Sometimes they throw an exception if the argument isn&#039;t valid. Right now they might just be doing a &quot;return myInt;&quot;, but tomorrow I may change that method to do something more complicated and then I don&#039;t have to go out and change the 50 different other classes that call the setter/getter.

Then there is the cases where:

a) You are using IOC/DI to set the properties in something like a Spring bean.
b) You are using something like iBatis where setters/getters are the convention for creating some bean from some mapped SQL.
c) You are implementing an interface where maybe someone else wants to add a proxy via AOP to wrap the getter/setter with additional code (validation, etc.)</description>
		<content:encoded><![CDATA[<p>For simple immutable value objects (in Java) that are nothing but containers for the attributes, then I have recently begun exposing the property directly by making it public. But that requires the values be passed in via the constructor or retrieved there, or made with a helper (which seems like a lot of trouble and adds extra maintenance and logic that can have bugs in it). So when there are more than a few properties that kind of falls flat on its face &#8211; who wants a constructor with 20 arguments? I use these &#8216;public&#8217; immutables for simple tuples of arguments that need to be grouped together when there are less than say 5 or so properties.</p>
<p>But what do getters/setters hide? Sometimes they hide validation. Sometimes they hide construction or retrieval of the property from somewhere else. Sometimes they hide a calculation. Sometimes they throw an exception if the argument isn&#8217;t valid. Right now they might just be doing a &#8220;return myInt;&#8221;, but tomorrow I may change that method to do something more complicated and then I don&#8217;t have to go out and change the 50 different other classes that call the setter/getter.</p>
<p>Then there is the cases where:</p>
<p>a) You are using IOC/DI to set the properties in something like a Spring bean.<br />
b) You are using something like iBatis where setters/getters are the convention for creating some bean from some mapped SQL.<br />
c) You are implementing an interface where maybe someone else wants to add a proxy via AOP to wrap the getter/setter with additional code (validation, etc.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://www.turnleafdesign.com/trends-getters-and-setters-going-the-way-of-the-dinosaur/comment-page-1#comment-84</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Fri, 09 Oct 2009 13:53:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.turnleafdesign.com/?p=101#comment-84</guid>
		<description>Trust me, you will appreciate them the moment you have to change the implementation of a property on a commonly used class.  That happened to me, but since the variables were protected instead of private I basically had to refactor 1200 class files to get them to use the getter.</description>
		<content:encoded><![CDATA[<p>Trust me, you will appreciate them the moment you have to change the implementation of a property on a commonly used class.  That happened to me, but since the variables were protected instead of private I basically had to refactor 1200 class files to get them to use the getter.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: javashlook</title>
		<link>http://www.turnleafdesign.com/trends-getters-and-setters-going-the-way-of-the-dinosaur/comment-page-1#comment-83</link>
		<dc:creator>javashlook</dc:creator>
		<pubDate>Fri, 09 Oct 2009 07:20:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.turnleafdesign.com/?p=101#comment-83</guid>
		<description>I was NEVER taught to use getter and setters to access the internal members of an external class. I think you pretty much misunderstand the issues of encapsulation and information hiding. How does having a setter/getter pair &quot;hides class&#039; implementation&quot;? Also, what kind of classes are you talking about, what kind of problem are you solving?</description>
		<content:encoded><![CDATA[<p>I was NEVER taught to use getter and setters to access the internal members of an external class. I think you pretty much misunderstand the issues of encapsulation and information hiding. How does having a setter/getter pair &#8220;hides class&#8217; implementation&#8221;? Also, what kind of classes are you talking about, what kind of problem are you solving?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: desing</title>
		<link>http://www.turnleafdesign.com/trends-getters-and-setters-going-the-way-of-the-dinosaur/comment-page-1#comment-7</link>
		<dc:creator>desing</dc:creator>
		<pubDate>Wed, 23 Sep 2009 22:23:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.turnleafdesign.com/?p=101#comment-7</guid>
		<description>In VB you dont even need to change your client code, you just have to recompile. But even that isnt good enough because if you dont recompile you break backwards compatibility.</description>
		<content:encoded><![CDATA[<p>In VB you dont even need to change your client code, you just have to recompile. But even that isnt good enough because if you dont recompile you break backwards compatibility.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

