<?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: Should one use Service Location or Service Injection</title>
	<atom:link href="http://www.dr-chuck.com/csev-blog/2006/10/should-one-use-service-location-or-service-injection/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dr-chuck.com/csev-blog/2006/10/should-one-use-service-location-or-service-injection/</link>
	<description>Teaching, Learning, Technology, Standards, Interoperability, etc.</description>
	<lastBuildDate>Wed, 08 Feb 2012 23:07:24 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Antranig Basman</title>
		<link>http://www.dr-chuck.com/csev-blog/2006/10/should-one-use-service-location-or-service-injection/comment-page-1/#comment-5</link>
		<dc:creator>Antranig Basman</dc:creator>
		<pubDate>Mon, 09 Oct 2006 17:32:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.dr-chuck.com/wordpress/?p=216#comment-5</guid>
		<description>Well, basically Andy said it all - there&#039;s not much to add. Always use injection where it is &quot;possible&quot;
Spring wiring is not just &quot;cool&quot;, it is *correct*. For all the reasons that Andy points out. People are legendarily bad at anticipating the use cases for their code. Just because you can&#039;t imagine the &quot;re-wire use case&quot; right now doesn&#039;t mean there isn&#039;t one. The Sakai codebase is littered with the design results of people who considered that their conception of the reusability of their code artefacts was the *correct* one for all time. A little more humility would have seen them use injection and admit that they didn&#039;t know it all.
Naturally this sort of thing is always going to be a judgement call - at some point the &quot;bean world&quot; stops, and &quot;normal code&quot; starts. But this conception that &quot;injection is only for big architecture boundaries&quot; is incredibly limiting, and reduces code quality.
I&#039;m also not a fan of moving &quot;code&quot; from Java to XML, but what you move into a Spring file is *not* code, it is configuration. Java code is for algorithms, XML is for configuration. It&#039;s always great to have everything in the right place.
Yeah, now the point about the &quot;scripting&quot; languages is very interesting. To the extent that they &quot;can&#039;t&quot; participate in injection, this indicates that there is something wrong with them - but on the other hand it makes perfect sense that a dynamic code artefact *also* needs to be able to express dynamic dependencies. I think the best way to deal with this problem would be to create some kind of &quot;mini-injection&quot; library that we use to host these things so that they can express their dependencies in a clear and documented way (but also in some kind of idiom appropriate for each language), rather than just blindly fetching beans and stuff whenever they want.
To me, these are environments for &quot;experimenting&quot; and &quot;prototyping&quot; in - and *always* at &#039;leaf nodes&#039; - I don&#039;t think anyone would dream of trying to create a &quot;bean&quot; in PHP/Ruby that could then participate in further injection - although I&#039;d be interested to hear some use cases for this :P
Once you have got your logic right and your tool is mature, you can take it out of the hands of the users/designers and &quot;upgrade&quot; it to a proper artefact using injection. This is why I am fond of the idea of getting designers to use BeanShell (http://www.beanshell.org/) for their &quot;experimental&quot; Sakai tools rather than Jython/PHP/Ruby, since once they are finished, the developers can inherit the code as is. All we need is a little &quot;packaging syntax&quot; for
scriptlets to declare their dependencies in a standardised way rather than grabbing the bean context explicitly.
It&#039;s all about *standardisation*, Chuck! And I know you like that. Going from Location -&gt; Injection is exactly the same kind of transition we had from Ant -&gt; Maven.
</description>
		<content:encoded><![CDATA[<p>Well, basically Andy said it all &#8211; there&#8217;s not much to add. Always use injection where it is &#8220;possible&#8221;<br />
Spring wiring is not just &#8220;cool&#8221;, it is *correct*. For all the reasons that Andy points out. People are legendarily bad at anticipating the use cases for their code. Just because you can&#8217;t imagine the &#8220;re-wire use case&#8221; right now doesn&#8217;t mean there isn&#8217;t one. The Sakai codebase is littered with the design results of people who considered that their conception of the reusability of their code artefacts was the *correct* one for all time. A little more humility would have seen them use injection and admit that they didn&#8217;t know it all.<br />
Naturally this sort of thing is always going to be a judgement call &#8211; at some point the &#8220;bean world&#8221; stops, and &#8220;normal code&#8221; starts. But this conception that &#8220;injection is only for big architecture boundaries&#8221; is incredibly limiting, and reduces code quality.<br />
I&#8217;m also not a fan of moving &#8220;code&#8221; from Java to XML, but what you move into a Spring file is *not* code, it is configuration. Java code is for algorithms, XML is for configuration. It&#8217;s always great to have everything in the right place.<br />
Yeah, now the point about the &#8220;scripting&#8221; languages is very interesting. To the extent that they &#8220;can&#8217;t&#8221; participate in injection, this indicates that there is something wrong with them &#8211; but on the other hand it makes perfect sense that a dynamic code artefact *also* needs to be able to express dynamic dependencies. I think the best way to deal with this problem would be to create some kind of &#8220;mini-injection&#8221; library that we use to host these things so that they can express their dependencies in a clear and documented way (but also in some kind of idiom appropriate for each language), rather than just blindly fetching beans and stuff whenever they want.<br />
To me, these are environments for &#8220;experimenting&#8221; and &#8220;prototyping&#8221; in &#8211; and *always* at &#8216;leaf nodes&#8217; &#8211; I don&#8217;t think anyone would dream of trying to create a &#8220;bean&#8221; in PHP/Ruby that could then participate in further injection &#8211; although I&#8217;d be interested to hear some use cases for this :P<br />
Once you have got your logic right and your tool is mature, you can take it out of the hands of the users/designers and &#8220;upgrade&#8221; it to a proper artefact using injection. This is why I am fond of the idea of getting designers to use BeanShell (<a href="http://www.beanshell.org/" rel="nofollow">http://www.beanshell.org/</a>) for their &#8220;experimental&#8221; Sakai tools rather than Jython/PHP/Ruby, since once they are finished, the developers can inherit the code as is. All we need is a little &#8220;packaging syntax&#8221; for<br />
scriptlets to declare their dependencies in a standardised way rather than grabbing the bean context explicitly.<br />
It&#8217;s all about *standardisation*, Chuck! And I know you like that. Going from Location -> Injection is exactly the same kind of transition we had from Ant -> Maven.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Severance</title>
		<link>http://www.dr-chuck.com/csev-blog/2006/10/should-one-use-service-location-or-service-injection/comment-page-1/#comment-4</link>
		<dc:creator>Charles Severance</dc:creator>
		<pubDate>Sat, 07 Oct 2006 17:49:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.dr-chuck.com/wordpress/?p=216#comment-4</guid>
		<description>Steven - Does Sash do vi?
</description>
		<content:encoded><![CDATA[<p>Steven &#8211; Does Sash do vi?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven Githens</title>
		<link>http://www.dr-chuck.com/csev-blog/2006/10/should-one-use-service-location-or-service-injection/comment-page-1/#comment-3</link>
		<dc:creator>Steven Githens</dc:creator>
		<pubDate>Sat, 07 Oct 2006 16:04:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.dr-chuck.com/wordpress/?p=216#comment-3</guid>
		<description>&gt;&quot;my IDE&quot; checks the syntax of the XML file - I say &gt;- sorry - vi does not do this :)
Nice vi shoutout.  :)
Any chance you&#039;ve gotten a head start on our javascript vi implementation?  ;)
</description>
		<content:encoded><![CDATA[<p>>&#8221;my IDE&#8221; checks the syntax of the XML file &#8211; I say >- sorry &#8211; vi does not do this :)<br />
Nice vi shoutout.  :)<br />
Any chance you&#8217;ve gotten a head start on our javascript vi implementation?  ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Thornton</title>
		<link>http://www.dr-chuck.com/csev-blog/2006/10/should-one-use-service-location-or-service-injection/comment-page-1/#comment-2</link>
		<dc:creator>Andrew Thornton</dc:creator>
		<pubDate>Sat, 07 Oct 2006 14:24:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.dr-chuck.com/wordpress/?p=216#comment-2</guid>
		<description>Sorry Chuck, gonna have to disagree with you on this... No doubt Nig&#039;ll drop in
too...
IMO service location is bad! The only time it&#039;s excusable to use it, is if
you&#039;re forced to use legacy view techs or broken apis. Even then you
should make serious effort to protect yourself from it.
- Everytime you use a cover you make it incredibly hard to unit test that class.
- Covers make it harder for a sys-admin to diagnose problems in a single tool&#039;s
use of an api.
- The use of Covers reduces your code reusability. OK in the case of the Sakai
Covers this is less of a problem, because e.g. it&#039;s unlikely that there will
ever be a second SiteService. However in general, Covers force your code to
live in the assumption of there only ever being one impl, when a later refactor
of an API make bring into existence a different usage pattern. (Yes in that case
you&#039;d have to rewrite, but we&#039;re asking how much do you need to rewrite...)
- A better solution for JSPs and other such dirty techs would be to pass in
objects for them to use. I cannot believe that anyone would think it a good
idea to write
&quot;&gt; may be a bit of text
You shouldn&#039;t be doing the work in the JSPs so just protect them from it. It
really isn&#039;t that hard to put things in requestAttributes and in the
pageContext maps so do that instead.
- How is injection hard to debug? I don&#039;t get that argument... I mean it&#039;s
either set in the application xml or it&#039;s not.
- I too find the XML nature of the wiring tiresome but there are things that
could be done to improve that. (Spring 2&#039;s dynamic conf, Simpler naming
schemes, Public/Private Spring contexts...)
- The confuse spring argument is simply wrong. You cannot *confuse* Spring, it&#039;s
not some animal in a black box, the rules that the ApplicationContext follows
are clear: The Dependency Graph must be Acyclic. (It can cope with some Cyclic
graphs, but IMO cyclicity is just wrong.) Every time you think you
need a cyclic dependency send Antranig an email. He&#039;s well versed in beetle
crushing.
- The complexity argument is bunken for tools anyway. Tools get wired up as the
webapps that contain them are started up. That means that the shared context
has already been completely created by the time the tool starts. Thus it should
be clear that anything that goes wrong with spring at that point is the tools
fault and cyclicity will be found there.
Thus, to reiterate only use Service Location if you&#039;re stuck using a dirty view
tech or a badly written api. Even then you should seriously look at what you&#039;re
doing, there&#039;s probably a better way to write your code so that you don&#039;t have
to do this.
andy
</description>
		<content:encoded><![CDATA[<p>Sorry Chuck, gonna have to disagree with you on this&#8230; No doubt Nig&#8217;ll drop in<br />
too&#8230;<br />
IMO service location is bad! The only time it&#8217;s excusable to use it, is if<br />
you&#8217;re forced to use legacy view techs or broken apis. Even then you<br />
should make serious effort to protect yourself from it.<br />
- Everytime you use a cover you make it incredibly hard to unit test that class.<br />
- Covers make it harder for a sys-admin to diagnose problems in a single tool&#8217;s<br />
use of an api.<br />
- The use of Covers reduces your code reusability. OK in the case of the Sakai<br />
Covers this is less of a problem, because e.g. it&#8217;s unlikely that there will<br />
ever be a second SiteService. However in general, Covers force your code to<br />
live in the assumption of there only ever being one impl, when a later refactor<br />
of an API make bring into existence a different usage pattern. (Yes in that case<br />
you&#8217;d have to rewrite, but we&#8217;re asking how much do you need to rewrite&#8230;)<br />
- A better solution for JSPs and other such dirty techs would be to pass in<br />
objects for them to use. I cannot believe that anyone would think it a good<br />
idea to write<br />
&#8220;> may be a bit of text<br />
You shouldn&#8217;t be doing the work in the JSPs so just protect them from it. It<br />
really isn&#8217;t that hard to put things in requestAttributes and in the<br />
pageContext maps so do that instead.<br />
- How is injection hard to debug? I don&#8217;t get that argument&#8230; I mean it&#8217;s<br />
either set in the application xml or it&#8217;s not.<br />
- I too find the XML nature of the wiring tiresome but there are things that<br />
could be done to improve that. (Spring 2&#8217;s dynamic conf, Simpler naming<br />
schemes, Public/Private Spring contexts&#8230;)<br />
- The confuse spring argument is simply wrong. You cannot *confuse* Spring, it&#8217;s<br />
not some animal in a black box, the rules that the ApplicationContext follows<br />
are clear: The Dependency Graph must be Acyclic. (It can cope with some Cyclic<br />
graphs, but IMO cyclicity is just wrong.) Every time you think you<br />
need a cyclic dependency send Antranig an email. He&#8217;s well versed in beetle<br />
crushing.<br />
- The complexity argument is bunken for tools anyway. Tools get wired up as the<br />
webapps that contain them are started up. That means that the shared context<br />
has already been completely created by the time the tool starts. Thus it should<br />
be clear that anything that goes wrong with spring at that point is the tools<br />
fault and cyclicity will be found there.<br />
Thus, to reiterate only use Service Location if you&#8217;re stuck using a dirty view<br />
tech or a badly written api. Even then you should seriously look at what you&#8217;re<br />
doing, there&#8217;s probably a better way to write your code so that you don&#8217;t have<br />
to do this.<br />
andy</p>
]]></content:encoded>
	</item>
</channel>
</rss>

