<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Why use Spring&#8230; if you have a HashMap at hand?</title>
	<atom:link href="http://lateralprogramming.wordpress.com/2008/04/07/why-use-spring-if-you-have-a-hashmap-at-hand/feed/" rel="self" type="application/rss+xml" />
	<link>http://lateralprogramming.wordpress.com/2008/04/07/why-use-spring-if-you-have-a-hashmap-at-hand/</link>
	<description>Coding out of the box</description>
	<lastBuildDate>Tue, 01 Jul 2008 18:09:29 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Mark Angrish</title>
		<link>http://lateralprogramming.wordpress.com/2008/04/07/why-use-spring-if-you-have-a-hashmap-at-hand/#comment-13</link>
		<dc:creator>Mark Angrish</dc:creator>
		<pubDate>Wed, 23 Apr 2008 10:05:20 +0000</pubDate>
		<guid isPermaLink="false">http://lateralprogramming.wordpress.com/?p=4#comment-13</guid>
		<description>Nice article.

I think with the rise of Java 5+/JEE 5 there is less and less a need for spring.  I like the simplicity of Guice, and while DI is just another way of doing something developers have always done, it does have its drawbacks which i think you have accurately captured.

Here is a comment i left on Kevin&#039;s (Guice co-creator) blog which talks along the same lines, and why i don&#039;t mind the Guice way!

http://smallwig.blogspot.com/2007/06/coupling.html#c347596939873173442</description>
		<content:encoded><![CDATA[<p>Nice article.</p>
<p>I think with the rise of Java 5+/JEE 5 there is less and less a need for spring.  I like the simplicity of Guice, and while DI is just another way of doing something developers have always done, it does have its drawbacks which i think you have accurately captured.</p>
<p>Here is a comment i left on Kevin&#8217;s (Guice co-creator) blog which talks along the same lines, and why i don&#8217;t mind the Guice way!</p>
<p><a href="http://smallwig.blogspot.com/2007/06/coupling.html#c347596939873173442" rel="nofollow">http://smallwig.blogspot.com/2007/06/coupling.html#c347596939873173442</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor</title>
		<link>http://lateralprogramming.wordpress.com/2008/04/07/why-use-spring-if-you-have-a-hashmap-at-hand/#comment-12</link>
		<dc:creator>Igor</dc:creator>
		<pubDate>Wed, 16 Apr 2008 12:22:56 +0000</pubDate>
		<guid isPermaLink="false">http://lateralprogramming.wordpress.com/?p=4#comment-12</guid>
		<description>If you want simple (but not simpler) container, you might want to try petite:
http://jodd.sourceforge.net/doc/petite.html
just two annotations, has auto-configuration, can work with proxies, it is aware of scopes.. and it is small;)</description>
		<content:encoded><![CDATA[<p>If you want simple (but not simpler) container, you might want to try petite:<br />
<a href="http://jodd.sourceforge.net/doc/petite.html" rel="nofollow">http://jodd.sourceforge.net/doc/petite.html</a><br />
just two annotations, has auto-configuration, can work with proxies, it is aware of scopes.. and it is small;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: KiLVaiDeN</title>
		<link>http://lateralprogramming.wordpress.com/2008/04/07/why-use-spring-if-you-have-a-hashmap-at-hand/#comment-11</link>
		<dc:creator>KiLVaiDeN</dc:creator>
		<pubDate>Fri, 11 Apr 2008 15:30:04 +0000</pubDate>
		<guid isPermaLink="false">http://lateralprogramming.wordpress.com/?p=4#comment-11</guid>
		<description>Just would like to point that obviously, the DI part of Spring is *NOT* the reason that makes it that popular.

The main advantage, is it&#039;s integration with different technologies and frameworks out there, and it&#039;s AOP oriented configuration which makes it very powerful.

K</description>
		<content:encoded><![CDATA[<p>Just would like to point that obviously, the DI part of Spring is *NOT* the reason that makes it that popular.</p>
<p>The main advantage, is it&#8217;s integration with different technologies and frameworks out there, and it&#8217;s AOP oriented configuration which makes it very powerful.</p>
<p>K</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eutrilla</title>
		<link>http://lateralprogramming.wordpress.com/2008/04/07/why-use-spring-if-you-have-a-hashmap-at-hand/#comment-10</link>
		<dc:creator>eutrilla</dc:creator>
		<pubDate>Fri, 11 Apr 2008 13:14:39 +0000</pubDate>
		<guid isPermaLink="false">http://lateralprogramming.wordpress.com/?p=4#comment-10</guid>
		<description>You&#039;re right, the named objects HashMap is rarely used, so it&#039;s not usually a problem for the dev to know where to look for something.  

By the way, there is a third option for the SessionFactory problem. ServiceLocators don&#039;t need to be accessed statically. So if you have two objects that require different Factories, you can pass different instances of the ServiceLocator to each object, each of which has a different instance for a given interface. Yes, that&#039;s DI, so what? I just need to pass one object. I&#039;ve never said that DI is bad, just that sometimes SL may be simpler. And the mix of both can be pretty good, too;D

Everything looks ugly in the corner cases. That&#039;s why they&#039;re corner cases, isn&#039;t it?</description>
		<content:encoded><![CDATA[<p>You&#8217;re right, the named objects HashMap is rarely used, so it&#8217;s not usually a problem for the dev to know where to look for something.  </p>
<p>By the way, there is a third option for the SessionFactory problem. ServiceLocators don&#8217;t need to be accessed statically. So if you have two objects that require different Factories, you can pass different instances of the ServiceLocator to each object, each of which has a different instance for a given interface. Yes, that&#8217;s DI, so what? I just need to pass one object. I&#8217;ve never said that DI is bad, just that sometimes SL may be simpler. And the mix of both can be pretty good, too;D</p>
<p>Everything looks ugly in the corner cases. That&#8217;s why they&#8217;re corner cases, isn&#8217;t it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://lateralprogramming.wordpress.com/2008/04/07/why-use-spring-if-you-have-a-hashmap-at-hand/#comment-9</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Fri, 11 Apr 2008 12:23:11 +0000</pubDate>
		<guid isPermaLink="false">http://lateralprogramming.wordpress.com/?p=4#comment-9</guid>
		<description>Boo!  My example didn&#039;t work:



Bean + one dependency on some DAO somewhere in the app context.  Write a simple test class that spins up the Spring app context like you want and you can verify before you do anything else that the bad label problem doesn&#039;t appear.</description>
		<content:encoded><![CDATA[<p>Boo!  My example didn&#8217;t work:</p>
<p>Bean + one dependency on some DAO somewhere in the app context.  Write a simple test class that spins up the Spring app context like you want and you can verify before you do anything else that the bad label problem doesn&#8217;t appear.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://lateralprogramming.wordpress.com/2008/04/07/why-use-spring-if-you-have-a-hashmap-at-hand/#comment-8</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Fri, 11 Apr 2008 12:20:54 +0000</pubDate>
		<guid isPermaLink="false">http://lateralprogramming.wordpress.com/?p=4#comment-8</guid>
		<description>&lt;blockquote&gt;
Actually, our ServiceLocator implementation has two HashMaps, one for services (i.e. identified by their class) and another one for general Objects (i.e. identified by a String).
&lt;/blockquote&gt;
Well, if the Maps contain the same configuration (different keys) you&#039;re beating DRY to death.  If they don&#039;t then a dev is going to have to know which one to go get or know to pass in a String this time and a class name the next to locate dependencies or use both in one class if one is by class the other by name.

&lt;blockquote&gt;
In the case you mention I’d think of two different approaches. The first one would be to store as a service a generic Factory that allows you to obtain the specific Factory you want.
&lt;/blockquote&gt;
Agreed that is a solution but you would now be introducing artificial object just get to around the configuration.  That factory would have no reason to be except as a workaround.
&lt;blockquote&gt;
The second option is to store it just as named objects.
&lt;/blockquote&gt;
Now you&#039;re back to your bad typing of labels problem....

&lt;blockquote&gt;
I think you left out all the bits where you tell Spring whether your sellerService is a Singleton or not, the scope, and so on. 
&lt;/blockquote&gt;
Wow.  In my version of Spring I usually need an id and a class attribute only for the bean definition itself.  Now I can use those other things if I want - but I don&#039;t have to:

&lt;code&gt;

&lt;/code&gt;

I only ended with a comment about the 4 lines containing &quot;XML&quot;. ;)  The majority of my comment is aimed at pointing out that when you approach the edge cases of usage the ServiceLocator will get &quot;ugly&quot; too.</description>
		<content:encoded><![CDATA[<blockquote><p>
Actually, our ServiceLocator implementation has two HashMaps, one for services (i.e. identified by their class) and another one for general Objects (i.e. identified by a String).
</p></blockquote>
<p>Well, if the Maps contain the same configuration (different keys) you&#8217;re beating DRY to death.  If they don&#8217;t then a dev is going to have to know which one to go get or know to pass in a String this time and a class name the next to locate dependencies or use both in one class if one is by class the other by name.</p>
<blockquote><p>
In the case you mention I’d think of two different approaches. The first one would be to store as a service a generic Factory that allows you to obtain the specific Factory you want.
</p></blockquote>
<p>Agreed that is a solution but you would now be introducing artificial object just get to around the configuration.  That factory would have no reason to be except as a workaround.</p>
<blockquote><p>
The second option is to store it just as named objects.
</p></blockquote>
<p>Now you&#8217;re back to your bad typing of labels problem&#8230;.</p>
<blockquote><p>
I think you left out all the bits where you tell Spring whether your sellerService is a Singleton or not, the scope, and so on.
</p></blockquote>
<p>Wow.  In my version of Spring I usually need an id and a class attribute only for the bean definition itself.  Now I can use those other things if I want &#8211; but I don&#8217;t have to:</p>
<p><code></p>
<p></code></p>
<p>I only ended with a comment about the 4 lines containing &#8220;XML&#8221;. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   The majority of my comment is aimed at pointing out that when you approach the edge cases of usage the ServiceLocator will get &#8220;ugly&#8221; too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: B Repko</title>
		<link>http://lateralprogramming.wordpress.com/2008/04/07/why-use-spring-if-you-have-a-hashmap-at-hand/#comment-7</link>
		<dc:creator>B Repko</dc:creator>
		<pubDate>Fri, 11 Apr 2008 09:14:25 +0000</pubDate>
		<guid isPermaLink="false">http://lateralprogramming.wordpress.com/?p=4#comment-7</guid>
		<description>OSGi is a service locator-based architecture btw so that is out there.  And DI uses SL in a sense that it looks up the dependency and then injects it.  The difference is that it does the lookup rather than the caller.  An extra level is put in there.  Both SL and DI can be mocked for testing so that&#039;s not a big deal.  I prefer SL when the object is remote or its availability may change because I like to know when it fails.  Otherwise, for component configuration, I&#039;ll use DI.</description>
		<content:encoded><![CDATA[<p>OSGi is a service locator-based architecture btw so that is out there.  And DI uses SL in a sense that it looks up the dependency and then injects it.  The difference is that it does the lookup rather than the caller.  An extra level is put in there.  Both SL and DI can be mocked for testing so that&#8217;s not a big deal.  I prefer SL when the object is remote or its availability may change because I like to know when it fails.  Otherwise, for component configuration, I&#8217;ll use DI.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eutrilla</title>
		<link>http://lateralprogramming.wordpress.com/2008/04/07/why-use-spring-if-you-have-a-hashmap-at-hand/#comment-6</link>
		<dc:creator>eutrilla</dc:creator>
		<pubDate>Fri, 11 Apr 2008 08:23:55 +0000</pubDate>
		<guid isPermaLink="false">http://lateralprogramming.wordpress.com/?p=4#comment-6</guid>
		<description>@Chris I mentioned the class-as-key as improvement because that helps keep things neat in the initialization and avoids potential problems related to bad typing of the labels. 
Actually, our ServiceLocator implementation has two HashMaps, one for services (i.e. identified by their class) and another one for general Objects (i.e. identified by a String). We found that useful to store global variables such as the current user name, the language to be used in the GUI and so on. You just have to be careful about what you store inside of it (you know, Global Variables Are Evil).

In the case you mention I&#039;d think of two different approaches. The first one would be to store as a service a generic Factory that allows you to obtain the specific Factory you want. The second option is to store it just as named objects. The point is that the ServiceLocator implementation is that easy that you can adapt it to whichever your needs are quite easily.

Just as a sidenote, yes, I agree that XML hell of Spring has already throughfully discussed, but since I was talking about the complexity of Spring I couldn&#039;t avoid to mention the most classic one ;D. But, indeed, I use the word &quot;XML&quot; just four times in a 90-ish line post. I devoted much more time to describe why it was harder to design components for use in DI than to nag about how much configuration I had to write. The whole point of the article is to compare the Service Locator pattern with the Dependency Injection patttern, and the popularity it has got due to Spring. But sadly, most of the comments (both here and at &lt;a href=&quot;http://www.dzone.com/links/why_use_spring_if_you_have_a_hashmap_at_hand.html&quot; rel=&quot;nofollow&quot;&gt;dzone&lt;/a&gt;) seems to be aimed at those four appearances of &quot;XML&quot;.</description>
		<content:encoded><![CDATA[<p>@Chris I mentioned the class-as-key as improvement because that helps keep things neat in the initialization and avoids potential problems related to bad typing of the labels.<br />
Actually, our ServiceLocator implementation has two HashMaps, one for services (i.e. identified by their class) and another one for general Objects (i.e. identified by a String). We found that useful to store global variables such as the current user name, the language to be used in the GUI and so on. You just have to be careful about what you store inside of it (you know, Global Variables Are Evil).</p>
<p>In the case you mention I&#8217;d think of two different approaches. The first one would be to store as a service a generic Factory that allows you to obtain the specific Factory you want. The second option is to store it just as named objects. The point is that the ServiceLocator implementation is that easy that you can adapt it to whichever your needs are quite easily.</p>
<p>Just as a sidenote, yes, I agree that XML hell of Spring has already throughfully discussed, but since I was talking about the complexity of Spring I couldn&#8217;t avoid to mention the most classic one ;D. But, indeed, I use the word &#8220;XML&#8221; just four times in a 90-ish line post. I devoted much more time to describe why it was harder to design components for use in DI than to nag about how much configuration I had to write. The whole point of the article is to compare the Service Locator pattern with the Dependency Injection patttern, and the popularity it has got due to Spring. But sadly, most of the comments (both here and at <a href="http://www.dzone.com/links/why_use_spring_if_you_have_a_hashmap_at_hand.html" rel="nofollow">dzone</a>) seems to be aimed at those four appearances of &#8220;XML&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eutrilla</title>
		<link>http://lateralprogramming.wordpress.com/2008/04/07/why-use-spring-if-you-have-a-hashmap-at-hand/#comment-5</link>
		<dc:creator>eutrilla</dc:creator>
		<pubDate>Fri, 11 Apr 2008 08:01:13 +0000</pubDate>
		<guid isPermaLink="false">http://lateralprogramming.wordpress.com/?p=4#comment-5</guid>
		<description>@Shannon I think you left out all the bits where you tell Spring whether your sellerService is a Singleton or not, the scope, and so on. Oh, yes, and you&#039;ll probably have to put several lines like that for each component. The more components in the app, the more fun.

Ok, how much could it be? 40 lines? 200 lines? 1000 lines? It may be not that much, but it just isn&#039;t really needed, and doesn&#039;t follow the KISS principle. Use it at your own risk.

Regarding the line about getting the service instance, the difference is that it is in the class that uses the service, not in the initialization. That means if that class is in another component, wherever I reuse it I don&#039;t have to explicitly provide that reference, whereas in DI I have to. And by the way, if I&#039;m not mistaken, the Spring equivalent is:

public void setLogger(Logger logger){
  this.logger = logger;
}</description>
		<content:encoded><![CDATA[<p>@Shannon I think you left out all the bits where you tell Spring whether your sellerService is a Singleton or not, the scope, and so on. Oh, yes, and you&#8217;ll probably have to put several lines like that for each component. The more components in the app, the more fun.</p>
<p>Ok, how much could it be? 40 lines? 200 lines? 1000 lines? It may be not that much, but it just isn&#8217;t really needed, and doesn&#8217;t follow the KISS principle. Use it at your own risk.</p>
<p>Regarding the line about getting the service instance, the difference is that it is in the class that uses the service, not in the initialization. That means if that class is in another component, wherever I reuse it I don&#8217;t have to explicitly provide that reference, whereas in DI I have to. And by the way, if I&#8217;m not mistaken, the Spring equivalent is:</p>
<p>public void setLogger(Logger logger){<br />
  this.logger = logger;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shanon McQuay</title>
		<link>http://lateralprogramming.wordpress.com/2008/04/07/why-use-spring-if-you-have-a-hashmap-at-hand/#comment-4</link>
		<dc:creator>Shanon McQuay</dc:creator>
		<pubDate>Fri, 11 Apr 2008 04:27:31 +0000</pubDate>
		<guid isPermaLink="false">http://lateralprogramming.wordpress.com/?p=4#comment-4</guid>
		<description>Sorry my spring config got swallowed by its html tags...

(property name=&quot;sellerService&quot;)(ref bean=&quot;sellerService&quot; /)(/property)</description>
		<content:encoded><![CDATA[<p>Sorry my spring config got swallowed by its html tags&#8230;</p>
<p>(property name=&#8221;sellerService&#8221;)(ref bean=&#8221;sellerService&#8221; /)(/property)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
