<?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: Venkat on Objects, Properties, and Constructors</title>
	<atom:link href="http://enfranchisedmind.com/blog/2007/04/15/venkat-on-objects-properties-and-constructors/feed/" rel="self" type="application/rss+xml" />
	<link>http://enfranchisedmind.com/blog/2007/04/15/venkat-on-objects-properties-and-constructors/</link>
	<description>Robert Fischer and Brian Hurt on Punditry, Programming Languages, and Other Religious Issues</description>
	<pubDate>Tue, 06 Jan 2009 14:00:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Enfranchised Mind &#187; Venkat on Functional Languages: I Knew He Was Smart</title>
		<link>http://enfranchisedmind.com/blog/2007/04/15/venkat-on-objects-properties-and-constructors/comment-page-1/#comment-31365</link>
		<dc:creator>Enfranchised Mind &#187; Venkat on Functional Languages: I Knew He Was Smart</dc:creator>
		<pubDate>Sat, 14 Jul 2007 16:24:30 +0000</pubDate>
		<guid isPermaLink="false">http://enfranchisedmind.com/blog/archive/2007/04/15/225#comment-31365</guid>
		<description>[...] Those of you in the functional programming community probably haven&#8217;t been hanging out at No Fluff Just Stuff conferences, and so you probably don&#8217;t know Dr. Venkat Subramaniam. That is really a shame, because he is a entertaining and informative presenter, as well as an insightful consultant who gets both the technical and business aspects of software development. This is all true and I deeply appreciate the guy&#8217;s work even though I disagree with his disdain for constructors. [...]</description>
		<content:encoded><![CDATA[<p>[...] Those of you in the functional programming community probably haven&#8217;t been hanging out at No Fluff Just Stuff conferences, and so you probably don&#8217;t know Dr. Venkat Subramaniam. That is really a shame, because he is a entertaining and informative presenter, as well as an insightful consultant who gets both the technical and business aspects of software development. This is all true and I deeply appreciate the guy&#8217;s work even though I disagree with his disdain for constructors. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert</title>
		<link>http://enfranchisedmind.com/blog/2007/04/15/venkat-on-objects-properties-and-constructors/comment-page-1/#comment-11953</link>
		<dc:creator>Robert</dc:creator>
		<pubDate>Mon, 16 Apr 2007 13:31:00 +0000</pubDate>
		<guid isPermaLink="false">http://enfranchisedmind.com/blog/archive/2007/04/15/225#comment-11953</guid>
		<description>To my exceedingly limited knowledge, Groovy doesn't have constructors at all -- Spring+Groovy, at least, doesn't support constructor injection.  I'll see if I can get someone more knowledgeable to comment.

I'm not a big fan of named arguments, particularly if I don't have a compiler: I've been bitten too many times in Perl by typoing an named argument.  Perl's error swallowing (e.g. silent conversion of &lt;code&gt;undef&lt;/code&gt; to the empty string) makes the situation all that much worse.

Why are none of the cases you've described supported through constructor injection?

Maybe I need to clarify my position a bit.  I support constructor injection for properties that are &lt;em&gt;mandatory&lt;/em&gt;: that is, for properties that are necessary to be set for the object to do its job.  Once set, I have no problem with the value being changed (including collections having elements added or removed) -- I just don't ever want to be able to get an object which isn't usable because it's partially configured.

Optional parameters, or parameters for which reasonable defaults can be inferred, should be left as accessor properties so that they can be cleanly ignored.  I've just realized (by meandering blogs) that some people are advocating setting &lt;em&gt;all&lt;/em&gt; properties at construction time.  That'd be nice if Java was a functional language, but I see where that rapidly becomes a serious pain (imagine trying to programmatically work with &lt;a href="http://jakarta.apache.org/commons/dbcp/apidocs/org/apache/commons/dbcp/BasicDataSource.html" target="v" rel="nofollow"&gt;BasicDataSource&lt;/a&gt; that way).</description>
		<content:encoded><![CDATA[<p>To my exceedingly limited knowledge, Groovy doesn&#8217;t have constructors at all &#8212; Spring+Groovy, at least, doesn&#8217;t support constructor injection.  I&#8217;ll see if I can get someone more knowledgeable to comment.</p>
<p>I&#8217;m not a big fan of named arguments, particularly if I don&#8217;t have a compiler: I&#8217;ve been bitten too many times in Perl by typoing an named argument.  Perl&#8217;s error swallowing (e.g. silent conversion of <code>undef</code> to the empty string) makes the situation all that much worse.</p>
<p>Why are none of the cases you&#8217;ve described supported through constructor injection?</p>
<p>Maybe I need to clarify my position a bit.  I support constructor injection for properties that are <em>mandatory</em>: that is, for properties that are necessary to be set for the object to do its job.  Once set, I have no problem with the value being changed (including collections having elements added or removed) &#8212; I just don&#8217;t ever want to be able to get an object which isn&#8217;t usable because it&#8217;s partially configured.</p>
<p>Optional parameters, or parameters for which reasonable defaults can be inferred, should be left as accessor properties so that they can be cleanly ignored.  I&#8217;ve just realized (by meandering blogs) that some people are advocating setting <em>all</em> properties at construction time.  That&#8217;d be nice if Java was a functional language, but I see where that rapidly becomes a serious pain (imagine trying to programmatically work with <a href="http://jakarta.apache.org/commons/dbcp/apidocs/org/apache/commons/dbcp/BasicDataSource.html" target="v" rel="nofollow">BasicDataSource</a> that way).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil Bartlett</title>
		<link>http://enfranchisedmind.com/blog/2007/04/15/venkat-on-objects-properties-and-constructors/comment-page-1/#comment-11922</link>
		<dc:creator>Neil Bartlett</dc:creator>
		<pubDate>Mon, 16 Apr 2007 08:52:24 +0000</pubDate>
		<guid isPermaLink="false">http://enfranchisedmind.com/blog/archive/2007/04/15/225#comment-11922</guid>
		<description>I tend to agree - the problem with constructor args being unnamed and therefore difficult to manage is just an issue with the Java language rather than anything deeply problematic about constructors in general. If one is willing to entertain other JVM-compiling languages such as Groovy, then this problem can be fixed. (NB I don't know Groovy so I have no idea if it has named constructor args, I'm just speaking theoretically).

However, the main limitation of contructor injection in my opinion is that it only supports dependencies that are mandatory, unary and static. When Spring-OSGi comes along, you're going to have more flexibility in all three of those dimensions: firstly, you're going to get "nice to have" dependencies, i.e. bean A would like to use bean B if it's available, but it can still do something useful even when it's not. Secondly, you might have twenty instances of bean B and A wants to know about them all. Thirdly, you're going to have beans that come and go, and a single instance of A might need to bind to multiple different instances of B during its lifetime. None of these use cases can be supported with constructor injection.

So, as with most things, constructor injection is nice, but not the solution for everything.</description>
		<content:encoded><![CDATA[<p>I tend to agree - the problem with constructor args being unnamed and therefore difficult to manage is just an issue with the Java language rather than anything deeply problematic about constructors in general. If one is willing to entertain other JVM-compiling languages such as Groovy, then this problem can be fixed. (NB I don&#8217;t know Groovy so I have no idea if it has named constructor args, I&#8217;m just speaking theoretically).</p>
<p>However, the main limitation of contructor injection in my opinion is that it only supports dependencies that are mandatory, unary and static. When Spring-OSGi comes along, you&#8217;re going to have more flexibility in all three of those dimensions: firstly, you&#8217;re going to get &#8220;nice to have&#8221; dependencies, i.e. bean A would like to use bean B if it&#8217;s available, but it can still do something useful even when it&#8217;s not. Secondly, you might have twenty instances of bean B and A wants to know about them all. Thirdly, you&#8217;re going to have beans that come and go, and a single instance of A might need to bind to multiple different instances of B during its lifetime. None of these use cases can be supported with constructor injection.</p>
<p>So, as with most things, constructor injection is nice, but not the solution for everything.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
