<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Geek on the Loose &#187; Java</title>
	<atom:link href="http://www.geekontheloose.com/programming/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geekontheloose.com</link>
	<description>Just another girl-geek weblog</description>
	<lastBuildDate>Thu, 25 Mar 2010 04:17:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Parallelism and Abstraction in Java</title>
		<link>http://www.geekontheloose.com/programming/java/parallelism-and-abstraction-in-java/</link>
		<comments>http://www.geekontheloose.com/programming/java/parallelism-and-abstraction-in-java/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 07:05:48 +0000</pubDate>
		<dc:creator>joulie</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.geekontheloose.com/?p=158</guid>
		<description><![CDATA[Here's an interesting parallel programming interview with Intel's Paul Guermonprez covering threads, JSR166y, and Hadoop. I particularly enjoyed the Hadoop discussion at the end.
The discussion focused on efforts to separate Java programming from the nitty gritty details of threads. This separation allows a greater number of developers to successfully program for parallel environment by removing [...]]]></description>
			<content:encoded><![CDATA[<p>Here's an interesting <a title="Parallel programming with Intel" rel="nofollow" href="http://software.intel.com/en-us/blogs/2010/01/28/parallel-programming-talk-61-parallel-java-with-intels-paul-guermonprez/">parallel programming interview with Intel's Paul Guermonprez</a> covering threads, JSR166y, and <a title="Apache Hadoop" rel="nofollow" href="http://hadoop.apache.org/">Hadoop</a>. I particularly enjoyed the Hadoop discussion at the end.</p>
<p>The discussion focused on efforts to separate Java programming from the nitty gritty details of threads. This separation allows a greater number of developers to successfully program for parallel environment by removing focus on the technical details, and thus reducing the knowledge required to write the code. There's also some coverage of the benefits of the higher level of abstraction of functional programming and how the functional programming style is being incorporated into the Java concurrency model. The text has this:</p>
<blockquote><p>The future will be functional programming or won't be at all.</p></blockquote>
<p>Intellectually, I applaud these efforts. Emotionally, I feel some loss.</p>
<p>My first introduction to threads was in a systems programming class, using the C language and Pthreads library. Pthreads blew my mind, or maybe it was lack of quality in the lectures. Either way, determined not to be defeated by Pthreads, I went out and bought a stack of books on Pthreads and threads in general and set out to wrap my mind around threads. It worked, but along the way, I learned that I loved the challenge and so I embraced concurrency and parallelism with much enthusiasm. This knowledge that I've accumulated will always be of great value, but as I move toward programming threads at further and further abstractions, I'll lose that close connection to the internals, and I'm a little saddened by that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekontheloose.com/programming/java/parallelism-and-abstraction-in-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dependency Injection and Inversion of Control</title>
		<link>http://www.geekontheloose.com/programming/java/dependency-injection-and-inversion-of-control/</link>
		<comments>http://www.geekontheloose.com/programming/java/dependency-injection-and-inversion-of-control/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 00:31:34 +0000</pubDate>
		<dc:creator>joulie</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.geekontheloose.com/?p=81</guid>
		<description><![CDATA[
I've been reading quite a few blog posts on dependency injection recently. I don't know why that's suddenly the topic to write about since it's been around for quite a while. I don't have any brilliant new revelations to offer, but just maybe a few thoughts in response to a blog post I read by [...]]]></description>
			<content:encoded><![CDATA[<p>
I've been reading quite a few blog posts on dependency injection recently. I don't know why that's suddenly the topic to write about since it's been around for quite a while. I don't have any brilliant new revelations to offer, but just maybe a few thoughts in response to a blog post I read by a Jordan Zimmerman, "Dependency Injection Makes Code Unintelligible"[1].
</p>
<p>
First, a couple of quick definitions from Wikipedia:
</p>
<p>
"Inversion of Control, or IoC, is an abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to the traditional architecture of software libraries."[2]
</p>
<p>
"Dependency Injection (DI) in computer programming refers to the process of supplying an external dependency to a software component. It is a specific form of inversion of control where the concern being inverted is the process of obtaining the needed dependency."[3]
</p>
<p>
The two topics I want to hit on from Jordan's post are testability of code that's been subjected to IoC/DI and, more trivially, the naming of dependency injection.</p>
<p><h4><span id="more-81"></span>What's in a Name?</h4>
<p>The term "Dependency Injection" was first published by Martin Fowler, who writes "Inversion of Control is too generic a term, and thus people find it confusing. As a result with a lot of discussion with various IoC advocates we settled on the name Dependency Injection."[4]
</p>
<p>
I can appreciate the desire to pin names onto various forms of IoC to separate them more clearly, but I disagree that the term "Inversion of Control" is a more confusing name compared to "Dependency Injection". What can be more clear than inverting control? I don't think dependency injection is anywhere near as clear. I'm probably not the first to say this, but inject it where exactly?
</p>
<p>
I was pleased to read that I'm not the only person in the world who's not thrilled with the DI terminology after reading Jordan's post[1]. I don't agree with everything he writes, but I'm also not thrilled with the term "dependency injection".
</p>
<p>
I'm going to use the term IoC going forward in this article, simply because that's the term I prefer. All examples are in Java, for simplicity, and also because most of the articles I read regarding DI/IoC are also using Java.</p>
<h4>Testability and Maintainability</h4>
<p>
I agree that IoC makes unit testing easier, much easier, by allowing us to easily mock portions of our applications, as is nicely explained by Miško Hevery[5]. (<a title="JMock" href="http://jmock.org/" rel="nofollow">JMock</a> is a terrific mock library, btw) Repeatable unit testing is a huge advantage of IoC, but at the same time, it's also a huge disadvantage because IoC makes integration testing and debugging much more difficult. This is because it becomes much harder to trace through the code due to the decoupling.
</p>
<p>
Regarding decoupling, Jordan writes, "We need some coupling so that we can understand how classes relate to one another. Maintainers of a code base need to be able to discover how various classes relate to one another and be able to trace class usage and interdependence. Hiding all of this complexity in XML files and annotations leaves the application impenetrable."[1]
</p>
<p>
I've always been a big believer in "read the code" and I love to read code, even bad code, because much can be learned from code. "What happens when you read some doc and either it doesn't answer your question or is demonstrably wrong? In Linux, you say 'Linux sucks' and go read the code. In Windows/Oracle/etc you say 'Windows sucks' and start banging your head against the wall", wrote Denis Vlasenko on the lkml.[6]
</p>
<p>
The decoupled nature of IoC, though, can turn a simple code-reading into a huge time-sink. Rather than diving in for a good read, the developer struggles to find which concrete class is actually invoked, then must discover which project/package that code actually belongs to, and finally must locate the actual source code for that project/package in the revision control tree before she can even begin to read the code.
</p>
<p>
I've experienced this first-hand in several different projects where I've taken over enhancing some code after a developer left the company, and it can be an exasperating experience. An enhancement is requested, or a bug is logged. Let's assume it's a bug. I might have been given an exception stack trace, and that at least gets me to a source code file to start from. I usually find a nice set of unit tests that I can run and quickly discover that they all pass - no big surprise there. They're all tests using mocked systems, though, so I'm unable to immediately reproduce the bug aside from being able to write a cute mock test to simulate how the code would respond to that particular error input, since I can easily mock the error. That's nice, but not very useful if my goal is to stop the error from happening in the first place.
</p>
<p>
Which concrete class is the actual perp? That's where it gets tricky. Most of the time, the stack trace gives no clue. Reading the code and examining XML files (or whatever method was involved for configuring the concrete classes used) can be a huge waste of time, and turns into a sort of tedious breadth-first search.
</p>
<p>
Is there a more direct way to find the perp? The best workaround I've found is to become very good with the debugger, and many times that means the remote debugger, and stepping deeply into the code until the likely culprit is found. That process will give a class name and package, but there's still some detective work to discover what project that belongs to. If you use version control and have lots of different projects created over many years of development with similarly named Java packages, that can be a nightmare, so let's just hope you work for a highly organized company that has everything documented in great detail so that finding the source code is a breeze.
</p>
<p>
The ability to quickly gather information and understand a program by reading the code is degraded by IoC because of the decoupling. It's important to recognize both the advantages and disadvantages of using IoC in your projects. I am a fan of IoC, but I always stop to give consideration for what future torture I may be inflicting on myself or others when I'm designing a project and try to plot the course with the minimum future pain.</p>
<h4>Summary</h4>
<p>
Miško Hevery asks us this question, "Should I be using dependency-injection?"[7] My answer to that is yes, no, maybe. The pains "injected" into code maintenance and integration testing by IoC aren't enough to be deal breakers, but they do point out the need for documentation and evaluation. Document what concrete classes are used for what functions, what packages they're in, where to find the tree in your source code repository. Make sure your documentation is easily accessible and up-to-date (my preference - a wiki, but that's for a separate post). Evaluate your project and ask if it would benefit from IoC. How will it be tested, maintained and used in the future? Use IoC when there's a good justification for using it and then use it responsibly, don't just use it because it's the big buzz word that everyone's using and it'll look good on your resume.</p>
<p>[1] <a title="Dependency Injection Makes Code Unintelligible" href="http://javaoldschool.blogspot.com/2009/01/dependency-injection-makes-code.html" rel="nofollow">Dependency Injection Makes Code Unintelligible</a><br />
[2] Wikipedia: <a title="Inversion of control" href="http://en.wikipedia.org/wiki/Inversion_of_control" rel="nofollow">Inversion of control</a><br />
[3] Wikipedia: <a title="dependency injection" href="http://en.wikipedia.org/wiki/Dependency_injection" rel="nofollow">Dependency injection</a><br />
[4] Martin Fowler: <a title="Inversion of control and dependency injection" href="http://www.martinfowler.com/articles/injection.html" rel="nofollow">Inversion of Control Containers and the Dependency Injection pattern</a><br />
[5] Miško Hevery: <a title="Unit testing and dependency injection" href="http://misko.hevery.com/2008/07/08/how-to-think-about-the-new-operator/" rel="nofollow">How to Think About the "new" Operator with Respect to Unit Testing</a><br />
[6] <a title="Top 50 Linux quotes" href="http://www.junauza.com/2008/01/top-50-linux-quotes-of-all-time.html" rel="nofollow">Top 50 Linux Quotes of All Time, #10</a> [note lkml == Linux Kernel Mailing List]<br />
[7] Miško Hevery: <a title="When to use dependency injection" href="http://java.dzone.com/articles/when-use-dependency-injection" rel="nofollow">When to Use Dependency Injection</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekontheloose.com/programming/java/dependency-injection-and-inversion-of-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Women Group Proposal</title>
		<link>http://www.geekontheloose.com/programming/java/java-women-group-proposal/</link>
		<comments>http://www.geekontheloose.com/programming/java/java-women-group-proposal/#comments</comments>
		<pubDate>Sun, 02 Sep 2007 23:01:08 +0000</pubDate>
		<dc:creator>joulie</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.geekontheloose.com/?p=41</guid>
		<description><![CDATA[
This week I received a forwarded email announcement about a new Java Women group being formed as part of the OpenJDK group. Being a Java devotee myself, it sounds perfect for me, so I'll be checking it out.


Here's the mission of the group as given on their wiki page: "The Java Women Network promotes collaboration [...]]]></description>
			<content:encoded><![CDATA[<p>
This week I received a forwarded email announcement about a new Java Women group being formed as part of the <a title="openJDK" href="http://openjdk.java.net/" target="_self" rel="nofollow">OpenJDK</a> group. Being a Java devotee myself, it sounds perfect for me, so I'll be checking it out.
</p>
<p>
Here's the mission of the group as given on their <a title="Java Women Network" href="http://wiki.java.net/bin/view/JDK/JavaWomen" target="_self" rel="nofollow">wiki page</a>: "The Java Women Network promotes collaboration amongst women who develop and use Java technology to increase the visibility of women's contribution, mentoring opportunities and professional networking."</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekontheloose.com/programming/java/java-women-group-proposal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
