<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-6252922358877820177.comments</id><updated>2011-08-27T18:34:55.280+02:00</updated><category term='dependency injection'/><category term='idea'/><category term='scala'/><category term='jdbc'/><category term='milestone'/><category term='analyzer'/><category term='qi4j'/><category term='java'/><category term='heap'/><category term='patterns'/><category term='development'/><category term='nullobject'/><category term='strategy'/><category term='maven'/><category term='mat'/><category term='memory'/><category term='concurrency'/><category term='book'/><category term='exceptions'/><category term='techtip'/><category term='sql'/><category term='spring'/><category term='parallel'/><category term='eclipse'/><category term='collections'/><category term='ubuntu'/><category term='architecture'/><category term='plugins'/><category term='subversion'/><category term='google'/><title type='text'>On the way to better software</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.krzysztofbialek.com/feeds/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/comments/default'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Krzysztof Białek</name><uri>http://www.blogger.com/profile/00013320014264918228</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://2.bp.blogspot.com/-m7eO378Pvbk/TV7eBsTjBuI/AAAAAAAABY8/gS1BgZctvJM/s220/kb.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6252922358877820177.post-4827010217782750058</id><published>2011-08-27T18:34:55.280+02:00</published><updated>2011-08-27T18:34:55.280+02:00</updated><title type='text'>Thank you.  This worked perfectly, and enabling fs...</title><content type='html'>Thank you.  This worked perfectly, and enabling fsc really helped with the make time.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/5955100165806474523/comments/default/4827010217782750058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/5955100165806474523/comments/default/4827010217782750058'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/2010/07/tech-tip-how-to-use-fast-scala-compiler.html?showComment=1314462895280#c4827010217782750058' title=''/><author><name>Jeremy Collins</name><uri>http://www.blogger.com/profile/04621400924466726069</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.krzysztofbialek.com/2010/07/tech-tip-how-to-use-fast-scala-compiler.html' ref='tag:blogger.com,1999:blog-6252922358877820177.post-5955100165806474523' source='http://www.blogger.com/feeds/6252922358877820177/posts/default/5955100165806474523' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-674995494'/></entry><entry><id>tag:blogger.com,1999:blog-6252922358877820177.post-1012185698540026680</id><published>2011-06-08T20:10:31.074+02:00</published><updated>2011-06-08T20:10:31.074+02:00</updated><title type='text'>Yikes!

If you want to use a set of indices rather...</title><content type='html'>Yikes!&lt;br /&gt;&lt;br /&gt;If you want to use a set of indices rather than Range(..), don&amp;#39;t forget to use a toSeq before the map!&lt;br /&gt;&lt;br /&gt;idxSet.toSeq.map(seq).sum</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/7840865291529952480/comments/default/1012185698540026680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/7840865291529952480/comments/default/1012185698540026680'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/2011/02/scala-collections-filtering-each-n-th.html?showComment=1307556631074#c1012185698540026680' title=''/><author><name>Laura Dietz</name><uri>http://www.mpii.de/~dietz</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.krzysztofbialek.com/2011/02/scala-collections-filtering-each-n-th.html' ref='tag:blogger.com,1999:blog-6252922358877820177.post-7840865291529952480' source='http://www.blogger.com/feeds/6252922358877820177/posts/default/7840865291529952480' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-699676136'/></entry><entry><id>tag:blogger.com,1999:blog-6252922358877820177.post-2161218225971360634</id><published>2011-03-13T14:48:08.682+01:00</published><updated>2011-03-13T14:48:08.682+01:00</updated><title type='text'>Regarding the IDEA options: As far as I can rememb...</title><content type='html'>Regarding the IDEA options: As far as I can remember I was trying all possible combinations without success.&lt;br /&gt;&lt;br /&gt;Regarding fsc port: When configured to use fsc, IDEA starts fsc client complier as separate java process and from my understanding the client is responsible for picking the right port by looking at &amp;quot;port&amp;quot; file in directory /tmp/scala-devel//scalac-compile-server-port/&lt;br /&gt;&lt;br /&gt;I hope that helps you.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/5955100165806474523/comments/default/2161218225971360634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/5955100165806474523/comments/default/2161218225971360634'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/2010/07/tech-tip-how-to-use-fast-scala-compiler.html?showComment=1300024088682#c2161218225971360634' title=''/><author><name>Krzysztof Białek</name><uri>http://www.blogger.com/profile/00013320014264918228</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://2.bp.blogspot.com/-m7eO378Pvbk/TV7eBsTjBuI/AAAAAAAABY8/gS1BgZctvJM/s220/kb.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.krzysztofbialek.com/2010/07/tech-tip-how-to-use-fast-scala-compiler.html' ref='tag:blogger.com,1999:blog-6252922358877820177.post-5955100165806474523' source='http://www.blogger.com/feeds/6252922358877820177/posts/default/5955100165806474523' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-518582357'/></entry><entry><id>tag:blogger.com,1999:blog-6252922358877820177.post-3416716935529156030</id><published>2011-03-13T12:30:08.858+01:00</published><updated>2011-03-13T12:30:08.858+01:00</updated><title type='text'>Do you do anything with idea options like:
 - rese...</title><content type='html'>Do you do anything with idea options like:&lt;br /&gt; - reset fsc server&lt;br /&gt; - shutdown fsc server&lt;br /&gt;?&lt;br /&gt;How IDEA knows to which port to connect?&lt;br /&gt;&lt;br /&gt;Thanks</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/5955100165806474523/comments/default/3416716935529156030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/5955100165806474523/comments/default/3416716935529156030'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/2010/07/tech-tip-how-to-use-fast-scala-compiler.html?showComment=1300015808858#c3416716935529156030' title=''/><author><name>Leszek Gruchała</name><uri>http://www.blogger.com/profile/00088047976523414378</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_63iqep0nnFY/TKOhTJ5iMfI/AAAAAAAABMQ/s7pnbkRt5sk/S220/ja3.JPG'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.krzysztofbialek.com/2010/07/tech-tip-how-to-use-fast-scala-compiler.html' ref='tag:blogger.com,1999:blog-6252922358877820177.post-5955100165806474523' source='http://www.blogger.com/feeds/6252922358877820177/posts/default/5955100165806474523' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1154854276'/></entry><entry><id>tag:blogger.com,1999:blog-6252922358877820177.post-1300424104693388637</id><published>2011-02-27T16:00:03.979+01:00</published><updated>2011-02-27T16:00:03.979+01:00</updated><title type='text'>Peter, you&amp;#39;re totally right. Non-indexed lists...</title><content type='html'>Peter, you&amp;#39;re totally right. Non-indexed lists are wrong choice for random access reads. I&amp;#39;ve tested Range-Map implementation once again with conversion in.toSeq replaced by in.toIndexedSeq. This time preformance is very good again also for non-indexed lists.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/1738047519690109951/comments/default/1300424104693388637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/1738047519690109951/comments/default/1300424104693388637'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/2011/02/scala-collections-filtering-each-n-th_24.html?showComment=1298818803979#c1300424104693388637' title=''/><author><name>Krzysztof Białek</name><uri>http://www.blogger.com/profile/00013320014264918228</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://2.bp.blogspot.com/-m7eO378Pvbk/TV7eBsTjBuI/AAAAAAAABY8/gS1BgZctvJM/s220/kb.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.krzysztofbialek.com/2011/02/scala-collections-filtering-each-n-th_24.html' ref='tag:blogger.com,1999:blog-6252922358877820177.post-1738047519690109951' source='http://www.blogger.com/feeds/6252922358877820177/posts/default/1738047519690109951' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-518582357'/></entry><entry><id>tag:blogger.com,1999:blog-6252922358877820177.post-7501168874006567468</id><published>2011-02-26T15:31:06.504+01:00</published><updated>2011-02-26T15:31:06.504+01:00</updated><title type='text'>The result of the benchmarks depend on the type of...</title><content type='html'>The result of the benchmarks depend on the type of the collection you are filtering. On Arrays, &lt;i&gt;filterUsingMap&lt;/i&gt; is fast, however on Lists its behaviour is terrible. &lt;br /&gt;&lt;br /&gt;This is because you use O(N) many indexed accesses, each of which is O(1) for arrays and O(N) for Lists. Thus &lt;i&gt;filterUsingMap&lt;/i&gt; is O(N) for arrays, but O(N*N) for lists.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/1738047519690109951/comments/default/7501168874006567468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/1738047519690109951/comments/default/7501168874006567468'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/2011/02/scala-collections-filtering-each-n-th_24.html?showComment=1298730666504#c7501168874006567468' title=''/><author><name>Peter</name><uri>http://www.blogger.com/profile/02456940077132303072</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.krzysztofbialek.com/2011/02/scala-collections-filtering-each-n-th_24.html' ref='tag:blogger.com,1999:blog-6252922358877820177.post-1738047519690109951' source='http://www.blogger.com/feeds/6252922358877820177/posts/default/1738047519690109951' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1275058767'/></entry><entry><id>tag:blogger.com,1999:blog-6252922358877820177.post-299580271934284052</id><published>2011-02-23T00:58:38.901+01:00</published><updated>2011-02-23T00:58:38.901+01:00</updated><title type='text'>Good idea, I like it.

Note that map(seq.apply(_))...</title><content type='html'>Good idea, I like it.&lt;br /&gt;&lt;br /&gt;Note that map(seq.apply(_)) can be shortened to just map(seq).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/7840865291529952480/comments/default/299580271934284052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/7840865291529952480/comments/default/299580271934284052'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/2011/02/scala-collections-filtering-each-n-th.html?showComment=1298419118901#c299580271934284052' title=''/><author><name>Seth Tisue</name><uri>http://www.blogger.com/profile/18193878850743685199</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_y-Qon5Eq6DE/SX0iUw9pGDI/AAAAAAAAAAM/qQcj9d5jceM/S220/79107734%40N00.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.krzysztofbialek.com/2011/02/scala-collections-filtering-each-n-th.html' ref='tag:blogger.com,1999:blog-6252922358877820177.post-7840865291529952480' source='http://www.blogger.com/feeds/6252922358877820177/posts/default/7840865291529952480' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1301412468'/></entry><entry><id>tag:blogger.com,1999:blog-6252922358877820177.post-8108609568551748585</id><published>2011-02-22T23:44:40.520+01:00</published><updated>2011-02-22T23:44:40.520+01:00</updated><title type='text'>Thanks for pointing this out. Using +: gives bette...</title><content type='html'>Thanks for pointing this out. Using +: gives better results. I&amp;#39;ve also tried with :: and it&amp;#39;s even faster.&lt;br /&gt;Btw, I figured out one more implementation which is very promising although it requires the collection to be a Seq: Range(offset, seq.size, step).map(seq.apply(_))&lt;br /&gt;Benchmarks will be published soon.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/7840865291529952480/comments/default/8108609568551748585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/7840865291529952480/comments/default/8108609568551748585'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/2011/02/scala-collections-filtering-each-n-th.html?showComment=1298414680520#c8108609568551748585' title=''/><author><name>Krzysztof Białek</name><uri>http://www.blogger.com/profile/00013320014264918228</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://2.bp.blogspot.com/-m7eO378Pvbk/TV7eBsTjBuI/AAAAAAAABY8/gS1BgZctvJM/s220/kb.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.krzysztofbialek.com/2011/02/scala-collections-filtering-each-n-th.html' ref='tag:blogger.com,1999:blog-6252922358877820177.post-7840865291529952480' source='http://www.blogger.com/feeds/6252922358877820177/posts/default/7840865291529952480' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-518582357'/></entry><entry><id>tag:blogger.com,1999:blog-6252922358877820177.post-1930275960376399590</id><published>2011-02-22T03:34:21.415+01:00</published><updated>2011-02-22T03:34:21.415+01:00</updated><title type='text'>#4 is O(n^2) overall because :+ is O(n) on List. +...</title><content type='html'>#4 is O(n^2) overall because :+ is O(n) on List. +: is O(1) though, so you could build up the list in reverse order and then reverse it at the end of the loop, reducing the overall runtime to O(n).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/7840865291529952480/comments/default/1930275960376399590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/7840865291529952480/comments/default/1930275960376399590'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/2011/02/scala-collections-filtering-each-n-th.html?showComment=1298342061415#c1930275960376399590' title=''/><author><name>Seth Tisue</name><uri>http://www.blogger.com/profile/18193878850743685199</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_y-Qon5Eq6DE/SX0iUw9pGDI/AAAAAAAAAAM/qQcj9d5jceM/S220/79107734%40N00.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.krzysztofbialek.com/2011/02/scala-collections-filtering-each-n-th.html' ref='tag:blogger.com,1999:blog-6252922358877820177.post-7840865291529952480' source='http://www.blogger.com/feeds/6252922358877820177/posts/default/7840865291529952480' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1301412468'/></entry><entry><id>tag:blogger.com,1999:blog-6252922358877820177.post-6252570116758594065</id><published>2011-01-30T08:16:29.303+01:00</published><updated>2011-01-30T08:16:29.303+01:00</updated><title type='text'>Thanks, Krysztof</title><content type='html'>Thanks, Krysztof</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/5955100165806474523/comments/default/6252570116758594065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/5955100165806474523/comments/default/6252570116758594065'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/2010/07/tech-tip-how-to-use-fast-scala-compiler.html?showComment=1296371789303#c6252570116758594065' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.krzysztofbialek.com/2010/07/tech-tip-how-to-use-fast-scala-compiler.html' ref='tag:blogger.com,1999:blog-6252922358877820177.post-5955100165806474523' source='http://www.blogger.com/feeds/6252922358877820177/posts/default/5955100165806474523' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-163684299'/></entry><entry><id>tag:blogger.com,1999:blog-6252922358877820177.post-6720566367098952544</id><published>2011-01-05T23:48:10.622+01:00</published><updated>2011-01-05T23:48:10.622+01:00</updated><title type='text'>Thank You, Krzysztof!
Your recipe does really help...</title><content type='html'>Thank You, Krzysztof!&lt;br /&gt;Your recipe does really help.&lt;br /&gt;&lt;br /&gt;I&amp;#39;ve added &amp;quot;fsc -shutdown&amp;quot; at the beginning of the bash script, too.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Eugen Labun</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/5955100165806474523/comments/default/6720566367098952544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/5955100165806474523/comments/default/6720566367098952544'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/2010/07/tech-tip-how-to-use-fast-scala-compiler.html?showComment=1294267690622#c6720566367098952544' title=''/><author><name>Eugen</name><uri>http://www.blogger.com/profile/02209030135825581786</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.krzysztofbialek.com/2010/07/tech-tip-how-to-use-fast-scala-compiler.html' ref='tag:blogger.com,1999:blog-6252922358877820177.post-5955100165806474523' source='http://www.blogger.com/feeds/6252922358877820177/posts/default/5955100165806474523' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-366286736'/></entry><entry><id>tag:blogger.com,1999:blog-6252922358877820177.post-8437466136699064096</id><published>2009-09-08T23:35:27.831+02:00</published><updated>2009-09-08T23:35:27.831+02:00</updated><title type='text'>I didn&amp;#39;t know Qi4j before. After reading your ...</title><content type='html'>I didn&amp;#39;t know Qi4j before. After reading your comment I know I need to have a closer look on it.&lt;br /&gt;And what are the werewolfs? There are several like wrong application architecture, ugly design, misuse of the tools.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/6890514210791168567/comments/default/8437466136699064096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/6890514210791168567/comments/default/8437466136699064096'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/2009/06/dependency-injection-bad-practices.html?showComment=1252445727831#c8437466136699064096' title=''/><author><name>Krzysztof Białek</name><uri>http://www.blogger.com/profile/00013320014264918228</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.krzysztofbialek.com/2009/06/dependency-injection-bad-practices.html' ref='tag:blogger.com,1999:blog-6252922358877820177.post-6890514210791168567' source='http://www.blogger.com/feeds/6252922358877820177/posts/default/6890514210791168567' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-518582357'/></entry><entry><id>tag:blogger.com,1999:blog-6252922358877820177.post-3500558139370690282</id><published>2009-09-02T06:05:55.547+02:00</published><updated>2009-09-02T06:05:55.547+02:00</updated><title type='text'>&amp;quot;If all you have is an object, everything loo...</title><content type='html'>&amp;quot;If all you have is an object, everything looks like a dependency.&amp;quot;&lt;br /&gt;&lt;br /&gt;  -- Niclas Hedhman, 2004&lt;br /&gt;&lt;br /&gt;You are right that DI is not a golden hammer, silver bullet (who/what is the werewolf?) or a magic trick to get your code in order. Quite contrary as you point out. Overuse, without scope and context management is a recipe for the very popular Bowl/Ball of Mud.&lt;br /&gt;&lt;br /&gt;Now, Rickard Oberg and I have long been struggling with architectural questions around good Java applications, he coming from the EJB failure and I from the Apache Avalon failure. Our combined effort of &amp;quot;assume everything is wrong&amp;quot; and &amp;quot;challenge everything&amp;quot; has (IMVHO) produced a lot of &amp;quot;forgotten&amp;quot; insights into Java development.&lt;br /&gt;&lt;br /&gt;The result is seen in &lt;a href="http://www.qi4j.org" rel="nofollow"&gt;Qi4j&lt;/a&gt; and what we call Composite Oriented Programming.&lt;br /&gt;&lt;br /&gt;In respect to this article, Dependency Injection is central, BUT it is scoped and limited. Scope means &amp;quot;from where can this come from&amp;quot; and with limited we mean &amp;quot;not anything can be injected&amp;quot;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@Service BankTeller teller;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;That is injection of a BankTeller service. Clear, concise, and since we make the declaration in code, we don&amp;#39;t need to juggle with the XML.&lt;br /&gt;&lt;br /&gt;JSR-330 also embraces the scope concept, but insist on doing so at the declaration and not at the injection;&lt;br /&gt;&lt;br /&gt;@Inject BankTeller teller;&lt;br /&gt;&lt;br /&gt;Is it a service, an entity or a plain value?? You must go to the declaration of BankTeller to find out. We think that simplifies writing, but makes reading much harder, and reading code is what needs to be simpler, not writing it.&lt;br /&gt;&lt;br /&gt;Another mechanism that we are using heavily in Qi4j, that isn&amp;#39;t thought of as Dependency Injection is the &amp;quot;Builder Pattern&amp;quot;.&lt;br /&gt;In Qi4j, you simply do;&lt;br /&gt;&lt;br /&gt;UnitOfWork uow = factory.currentUnitOfWork();&lt;br /&gt;&lt;br /&gt;EntityBuilder&amp;lt;User&amp;gt; builder = uow.newEntityBuilder( User.class );&lt;br /&gt;&lt;br /&gt;User proto = builder.instance();&lt;br /&gt;proto.name().set( &amp;quot;Niclas Hedhman&amp;quot; );&lt;br /&gt;:&lt;br /&gt;:&lt;br /&gt;User user = builder.newInstance();&lt;br /&gt;&lt;br /&gt;where,&lt;br /&gt;&lt;br /&gt;public interface User&lt;br /&gt;{&lt;br /&gt;    Property&amp;lt;String&amp;gt; name();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Now, since User is a interface it can not be instantiated. But, we provide a way to make declarations of visibility and mapping between a domain interface and a Composite (kind-of object),&lt;br /&gt;&lt;br /&gt;public interface UserEntity extends User, EntityComposite&lt;br /&gt;{}&lt;br /&gt;&lt;br /&gt;and&lt;br /&gt;&lt;br /&gt;public void assemble( ModuleAssembly module )&lt;br /&gt;{&lt;br /&gt;    module.addEntities( UserEntity.class );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This gives us really simple mechanisms for &amp;#39;injection&amp;#39; of what type is going to be used, for instance for TDD, but could be a &amp;#39;sandboxed&amp;#39; environment, &amp;#39;staging&amp;#39;, &amp;#39;secured&amp;#39; and so forth.&lt;br /&gt;&lt;br /&gt;Builder patterns can easily be deployed for many of the Dependency Injection tasks without framework support or even if Spring Framework is the &amp;#39;base architecture&amp;#39; (shrug) to minimize the amount of XML that needs to be juggled.&lt;br /&gt;&lt;br /&gt;Spring has a large set of problems as a DI framework, from the idiotic idea that the presence of getAbc()/setAbc() makes Abc a property, to that everything should be injected, therefor institutionalizing the idea that object creation is best left to clients (*shrug*).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/6890514210791168567/comments/default/3500558139370690282'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6252922358877820177/6890514210791168567/comments/default/3500558139370690282'/><link rel='alternate' type='text/html' href='http://www.krzysztofbialek.com/2009/06/dependency-injection-bad-practices.html?showComment=1251864355547#c3500558139370690282' title=''/><author><name>Niclas</name><uri>http://www.blogger.com/profile/00395199829406869265</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.krzysztofbialek.com/2009/06/dependency-injection-bad-practices.html' ref='tag:blogger.com,1999:blog-6252922358877820177.post-6890514210791168567' source='http://www.blogger.com/feeds/6252922358877820177/posts/default/6890514210791168567' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1212268008'/></entry></feed>
