<?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: More on boilerplate and IoC</title>
	<atom:link href="http://herebebeasties.com/2006-12-06/more-on-boilerplate-and-ioc/feed/" rel="self" type="application/rss+xml" />
	<link>http://herebebeasties.com/2006-12-06/more-on-boilerplate-and-ioc/</link>
	<description>Alastair Maw's small soap box.</description>
	<lastBuildDate>Thu, 10 Nov 2011 14:24:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Alastair</title>
		<link>http://herebebeasties.com/2006-12-06/more-on-boilerplate-and-ioc/comment-page-1/#comment-1002</link>
		<dc:creator>Alastair</dc:creator>
		<pubDate>Wed, 14 Mar 2007 17:31:26 +0000</pubDate>
		<guid isPermaLink="false">http://almaw.com/2006-12-06/more-on-boilerplate-and-ioc/#comment-1002</guid>
		<description>Thanks for the comments. :)

I appreciate there are many reasons to encapsulate things with getters/setters. I&#039;m just railing against the most common use case. Tools should make 80% of your job easy and the remaining 20% possible. Java seems to fail somewhat on simple things like this.

I completely agree on the benefit of first-class properties in Java for things like Hibernate (Wicket could also use this for PropertyModels and the like). I&#039;d really, really like that and was saving a rant about it for another day. It would make usage of things like Hibernate and Wicket so much nicer.</description>
		<content:encoded><![CDATA[<p>Thanks for the comments. :)</p>
<p>I appreciate there are many reasons to encapsulate things with getters/setters. I&#8217;m just railing against the most common use case. Tools should make 80% of your job easy and the remaining 20% possible. Java seems to fail somewhat on simple things like this.</p>
<p>I completely agree on the benefit of first-class properties in Java for things like Hibernate (Wicket could also use this for PropertyModels and the like). I&#8217;d really, really like that and was saving a rant about it for another day. It would make usage of things like Hibernate and Wicket so much nicer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frits Jalvingh</title>
		<link>http://herebebeasties.com/2006-12-06/more-on-boilerplate-and-ioc/comment-page-1/#comment-997</link>
		<dc:creator>Frits Jalvingh</dc:creator>
		<pubDate>Wed, 14 Mar 2007 16:44:49 +0000</pubDate>
		<guid isPermaLink="false">http://almaw.com/2006-12-06/more-on-boilerplate-and-ioc/#comment-997</guid>
		<description>I disagree with you wrt the public fields issue. There are many reasons to encapsulate access to some data field other than dynamic proxying and other stuff. Data hiding can really help if your application matures and changes.

That said I agree that writing setters and getters is moronic and that the language should provide ways to easily create them //when needed// without it being visible to calling code, so that we can change something like:

property long count;

to

property long count set { .... } 

while all the time using the property itself in code like
c.count = c.count + 1;

This would at least fix the heaps of boilerplate crap present in most POJO classes.

But even more important than preventing the zillion of stupid &quot;getters and setters&quot; is having this in place to create //property references// from code.

Lots of frameworks need to refer to objects and properties of objects from within code. Take for instance Hibernate; when issuing a query you can easily create a class reference using something like &quot;User.class&quot;. But creating a criteria query on the user&#039;s &#039;name&#039; property must be done by coding the &quot;name&quot; field as a string:
c.add( Restrictions.eq(&quot;name&quot;, &quot;Jalvingh&quot;));

This makes most frameworks very fragile wrt refactoring and data changes, and it makes the reference invisible to most tools making change impact analysis hard.

Having properties as first-class elements in the language would make it possible to encode references to these properties which can then be checked at compile time by the compiler, and are visible to frameworks and IDE&#039;s. For me this is the //real// value of  properties syntax in Java.

As far as your comments on the Spring framework go: I mostly agree. Although I really like IOC when it is used to remove framework and factory references from beans, I am not impressed by the Spring way of configuring things. This is where I partly disagree with myth #4: having beans that do not contain references to the factories for the dao implementations are worth having; it really cleans up the code and removes dependencies not worth having.

Spring configuration is indeed a disaster. One gets a complete heap of &quot;code&quot; (in XML) that is invisible to any tooling. And this &quot;code&quot; forms a considerable amount of your application! I also dislike the many highly technical tricks needed to get stuff to work. If that much trickery is needed replacing Spring with something else might be very hard indeed.

Something that also bothers me is that although it is easy to keep simple code clean from Spring dependencies internally this is not doable when using many of the Spring &quot;enhancements&quot;. Take for instance the Hibernate DAO layer encoded with Spring - it enforces your DAO&#039;s to be derived from a Spring base class to handle declarative transaction management... Gross.</description>
		<content:encoded><![CDATA[<p>I disagree with you wrt the public fields issue. There are many reasons to encapsulate access to some data field other than dynamic proxying and other stuff. Data hiding can really help if your application matures and changes.</p>
<p>That said I agree that writing setters and getters is moronic and that the language should provide ways to easily create them //when needed// without it being visible to calling code, so that we can change something like:</p>
<p>property long count;</p>
<p>to</p>
<p>property long count set { &#8230;. } </p>
<p>while all the time using the property itself in code like<br />
c.count = c.count + 1;</p>
<p>This would at least fix the heaps of boilerplate crap present in most POJO classes.</p>
<p>But even more important than preventing the zillion of stupid &#8220;getters and setters&#8221; is having this in place to create //property references// from code.</p>
<p>Lots of frameworks need to refer to objects and properties of objects from within code. Take for instance Hibernate; when issuing a query you can easily create a class reference using something like &#8220;User.class&#8221;. But creating a criteria query on the user&#8217;s &#8216;name&#8217; property must be done by coding the &#8220;name&#8221; field as a string:<br />
c.add( Restrictions.eq(&#8220;name&#8221;, &#8220;Jalvingh&#8221;));</p>
<p>This makes most frameworks very fragile wrt refactoring and data changes, and it makes the reference invisible to most tools making change impact analysis hard.</p>
<p>Having properties as first-class elements in the language would make it possible to encode references to these properties which can then be checked at compile time by the compiler, and are visible to frameworks and IDE&#8217;s. For me this is the //real// value of  properties syntax in Java.</p>
<p>As far as your comments on the Spring framework go: I mostly agree. Although I really like IOC when it is used to remove framework and factory references from beans, I am not impressed by the Spring way of configuring things. This is where I partly disagree with myth #4: having beans that do not contain references to the factories for the dao implementations are worth having; it really cleans up the code and removes dependencies not worth having.</p>
<p>Spring configuration is indeed a disaster. One gets a complete heap of &#8220;code&#8221; (in XML) that is invisible to any tooling. And this &#8220;code&#8221; forms a considerable amount of your application! I also dislike the many highly technical tricks needed to get stuff to work. If that much trickery is needed replacing Spring with something else might be very hard indeed.</p>
<p>Something that also bothers me is that although it is easy to keep simple code clean from Spring dependencies internally this is not doable when using many of the Spring &#8220;enhancements&#8221;. Take for instance the Hibernate DAO layer encoded with Spring &#8211; it enforces your DAO&#8217;s to be derived from a Spring base class to handle declarative transaction management&#8230; Gross.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

