<?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: Exposing collections: paranoia vs trust approaches</title>
	<atom:link href="http://chaoticjava.com/posts/exposing-collections-paranoia-vs-trust-approaches/feed/" rel="self" type="application/rss+xml" />
	<link>http://chaoticjava.com/posts/exposing-collections-paranoia-vs-trust-approaches/</link>
	<description>The internet, design patterns, frameworks and Java</description>
	<lastBuildDate>Fri, 05 Mar 2010 16:13:23 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Khalil</title>
		<link>http://chaoticjava.com/posts/exposing-collections-paranoia-vs-trust-approaches/comment-page-1/#comment-31989</link>
		<dc:creator>Khalil</dc:creator>
		<pubDate>Mon, 26 May 2008 22:14:13 +0000</pubDate>
		<guid isPermaLink="false">http://chaoticjava.com/?p=236#comment-31989</guid>
		<description>Rather  than providing a List getElements() kind of method you would have BGGA style http://www.javac.info 
 
withElements( {Element=&gt;void throws X} closure){
      for(Element elt:elements) closure.invoke(element);
} 

in client code you would write control invocation syntax 
for withElements(Element elt){ 
     System.out.println(elt); 
}</description>
		<content:encoded><![CDATA[<p>Rather  than providing a List getElements() kind of method you would have BGGA style <a href="http://www.javac.info" rel="nofollow">http://www.javac.info</a> </p>
<p>withElements( {Element=&gt;void throws X} closure){<br />
      for(Element elt:elements) closure.invoke(element);<br />
} </p>
<p>in client code you would write control invocation syntax<br />
for withElements(Element elt){<br />
     System.out.println(elt);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aviad</title>
		<link>http://chaoticjava.com/posts/exposing-collections-paranoia-vs-trust-approaches/comment-page-1/#comment-31987</link>
		<dc:creator>Aviad</dc:creator>
		<pubDate>Mon, 26 May 2008 19:49:28 +0000</pubDate>
		<guid isPermaLink="false">http://chaoticjava.com/?p=236#comment-31987</guid>
		<description>@Khalil: while I agree that closures shine on many fields, I fail to see how they help with this specific case... Can you please elaborate?</description>
		<content:encoded><![CDATA[<p>@Khalil: while I agree that closures shine on many fields, I fail to see how they help with this specific case&#8230; Can you please elaborate?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Khalil</title>
		<link>http://chaoticjava.com/posts/exposing-collections-paranoia-vs-trust-approaches/comment-page-1/#comment-31929</link>
		<dc:creator>Khalil</dc:creator>
		<pubDate>Sun, 25 May 2008 12:36:21 +0000</pubDate>
		<guid isPermaLink="false">http://chaoticjava.com/?p=236#comment-31929</guid>
		<description>This is an area where closures  shine,  they preserve encapsulation and would save memory, of course they don&#039;t solve the issue with frameworks that need to muck with your collection</description>
		<content:encoded><![CDATA[<p>This is an area where closures  shine,  they preserve encapsulation and would save memory, of course they don&#8217;t solve the issue with frameworks that need to muck with your collection</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aviad</title>
		<link>http://chaoticjava.com/posts/exposing-collections-paranoia-vs-trust-approaches/comment-page-1/#comment-31764</link>
		<dc:creator>Aviad</dc:creator>
		<pubDate>Thu, 22 May 2008 03:15:37 +0000</pubDate>
		<guid isPermaLink="false">http://chaoticjava.com/?p=236#comment-31764</guid>
		<description>@Adrian: I actually like your approach better than James&#039;, as it allows me to have the collection contained in some other support class (see my answer to James)

Still, I think it breaks encapsulation, and makes it harder to unit-test the code, as it would be impossible to test the &quot;setCollection&quot; method, it being private.</description>
		<content:encoded><![CDATA[<p>@Adrian: I actually like your approach better than James&#8217;, as it allows me to have the collection contained in some other support class (see my answer to James)</p>
<p>Still, I think it breaks encapsulation, and makes it harder to unit-test the code, as it would be impossible to test the &#8220;setCollection&#8221; method, it being private.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian Smith</title>
		<link>http://chaoticjava.com/posts/exposing-collections-paranoia-vs-trust-approaches/comment-page-1/#comment-31748</link>
		<dc:creator>Adrian Smith</dc:creator>
		<pubDate>Wed, 21 May 2008 16:05:11 +0000</pubDate>
		<guid isPermaLink="false">http://chaoticjava.com/?p=236#comment-31748</guid>
		<description>@James - Nice one, I hadn&#039;t thought of doing that.

What I always do, to implement the paranoia approach with Hibernate, is to create &quot;private&quot; getters and setters for the actual List or whatever. That way noone can call them, but it works just fine with Hibernate. Then create other methods addItem or whatever, that I want other people to call.</description>
		<content:encoded><![CDATA[<p>@James &#8211; Nice one, I hadn&#8217;t thought of doing that.</p>
<p>What I always do, to implement the paranoia approach with Hibernate, is to create &#8220;private&#8221; getters and setters for the actual List or whatever. That way noone can call them, but it works just fine with Hibernate. Then create other methods addItem or whatever, that I want other people to call.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aviad</title>
		<link>http://chaoticjava.com/posts/exposing-collections-paranoia-vs-trust-approaches/comment-page-1/#comment-31692</link>
		<dc:creator>Aviad</dc:creator>
		<pubDate>Tue, 20 May 2008 19:05:30 +0000</pubDate>
		<guid isPermaLink="false">http://chaoticjava.com/?p=236#comment-31692</guid>
		<description>@All: I&#039;m sorry about the connection problems... I should really switch the current hosting plan to a better one.

@Paul: You&#039;re right, but that still doesn&#039;t give you the access required to write to the fields...</description>
		<content:encoded><![CDATA[<p>@All: I&#8217;m sorry about the connection problems&#8230; I should really switch the current hosting plan to a better one.</p>
<p>@Paul: You&#8217;re right, but that still doesn&#8217;t give you the access required to write to the fields&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://chaoticjava.com/posts/exposing-collections-paranoia-vs-trust-approaches/comment-page-1/#comment-31687</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Tue, 20 May 2008 18:31:44 +0000</pubDate>
		<guid isPermaLink="false">http://chaoticjava.com/?p=236#comment-31687</guid>
		<description>First comment gave me a connection error so sorry if this is a duplicate.  The reflection api gives access to a classes private members via the getDeclaredFields method:

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#getDeclaredFields()

... &quot;This includes public, protected, default (package) access, and private fields,...&quot;</description>
		<content:encoded><![CDATA[<p>First comment gave me a connection error so sorry if this is a duplicate.  The reflection api gives access to a classes private members via the getDeclaredFields method:</p>
<p><a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#getDeclaredFields()" rel="nofollow">http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#getDeclaredFields()</a></p>
<p>&#8230; &#8220;This includes public, protected, default (package) access, and private fields,&#8230;&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aviad</title>
		<link>http://chaoticjava.com/posts/exposing-collections-paranoia-vs-trust-approaches/comment-page-1/#comment-31685</link>
		<dc:creator>Aviad</dc:creator>
		<pubDate>Tue, 20 May 2008 17:27:19 +0000</pubDate>
		<guid isPermaLink="false">http://chaoticjava.com/?p=236#comment-31685</guid>
		<description>@Brian: You&#039;re right - but as I remember, and correct me if I&#039;m wrong, it also requires special permissions (a specific flag in ReflectPermission?)</description>
		<content:encoded><![CDATA[<p>@Brian: You&#8217;re right &#8211; but as I remember, and correct me if I&#8217;m wrong, it also requires special permissions (a specific flag in ReflectPermission?)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Duff</title>
		<link>http://chaoticjava.com/posts/exposing-collections-paranoia-vs-trust-approaches/comment-page-1/#comment-31682</link>
		<dc:creator>Brian Duff</dc:creator>
		<pubDate>Tue, 20 May 2008 16:05:37 +0000</pubDate>
		<guid isPermaLink="false">http://chaoticjava.com/?p=236#comment-31682</guid>
		<description>It probably uses the setAccessible() method on java.lang.reflect.Field. If you make a field accessible, you can set it using reflection even if it&#039;s private. Breaks encapsulation for sure, but a useful trick for injection frameworks.</description>
		<content:encoded><![CDATA[<p>It probably uses the setAccessible() method on java.lang.reflect.Field. If you make a field accessible, you can set it using reflection even if it&#8217;s private. Breaks encapsulation for sure, but a useful trick for injection frameworks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian Smith</title>
		<link>http://chaoticjava.com/posts/exposing-collections-paranoia-vs-trust-approaches/comment-page-1/#comment-31678</link>
		<dc:creator>Adrian Smith</dc:creator>
		<pubDate>Tue, 20 May 2008 14:51:50 +0000</pubDate>
		<guid isPermaLink="false">http://chaoticjava.com/?p=236#comment-31678</guid>
		<description>http://www.databasesandlife.com/encapsulation-or-public-attributes-but-nothing-inbetween/

(Oh if only things like pingback and trackback would just work!)</description>
		<content:encoded><![CDATA[<p><a href="http://www.databasesandlife.com/encapsulation-or-public-attributes-but-nothing-inbetween/" rel="nofollow">http://www.databasesandlife.com/encapsulation-or-public-attributes-but-nothing-inbetween/</a></p>
<p>(Oh if only things like pingback and trackback would just work!)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
