<?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: Unit Testing and the Law of Demeter</title>
	<atom:link href="http://www.hermanradtke.com/blog/unit-testing-and-the-law-of-demeter/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hermanradtke.com/blog/unit-testing-and-the-law-of-demeter/</link>
	<description>Personal anecdotes from my experiences using the LAMP stack</description>
	<lastBuildDate>Mon, 30 Aug 2010 07:16:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Herman Radtke</title>
		<link>http://www.hermanradtke.com/blog/unit-testing-and-the-law-of-demeter/comment-page-1/#comment-3481</link>
		<dc:creator>Herman Radtke</dc:creator>
		<pubDate>Thu, 25 Mar 2010 16:16:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.hermanradtke.com/blog/?p=287#comment-3481</guid>
		<description>Looking at this post again, you are correct.  This was just contrived example, but it definitely violates some OO principles.  I can&#039;t remember exactly what I was working on when I decided to post this, but it makes me want to review it and make sure I did not make the same mistake there.

Thanks for keeping me honest!</description>
		<content:encoded><![CDATA[<p>Looking at this post again, you are correct.  This was just contrived example, but it definitely violates some OO principles.  I can&#8217;t remember exactly what I was working on when I decided to post this, but it makes me want to review it and make sure I did not make the same mistake there.</p>
<p>Thanks for keeping me honest!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Kleijn</title>
		<link>http://www.hermanradtke.com/blog/unit-testing-and-the-law-of-demeter/comment-page-1/#comment-3480</link>
		<dc:creator>John Kleijn</dc:creator>
		<pubDate>Thu, 25 Mar 2010 08:31:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.hermanradtke.com/blog/?p=287#comment-3480</guid>
		<description>I am leaning toward disagreement about the parse method. Passing the subject of the parsing really doesn&#039;t constitute a stateful interface in its current form (the method might as well have been defined as static). But lets say the parsing is a more involves process, that does require certain instance variables. Wouldn&#039;t it then be more appropriate to &quot;encapsulate the concept that varies&quot;, and create a &quot;PersonNameParser&quot;? In fact, I think that would be more appropriate in any case, unless you intend the parsed name to be the default output (merged with &quot;getFullName&quot;).

My point is that I think it defeats the purpose of a domain object to request operations on the state of that same object. Actually I think you&#039;ve done the exact opposite of Tell Don&#039;t Ask. Tell Don&#039;t Ask doesn&#039;t mean &quot;pass arguments instead of using internal state&quot;, it means &quot;decisions based entirely upon the state of one object should be made &#039;inside&#039; the object itself&quot;. And in trying to improve testability you actually violated that and broke encapsulation. Because the decision of what to use an argument to explode() has effectively been delegated to the client.

Sure, one should try to keep to the Law of Demeter to avoid &quot;train wrecks&quot; and improve cohesion on a package or application level, but I don&#039;t think that extends to methods used within the same class to fetch internal state.

On a side note I think you have very nice blog here. I came across it when looking for info about Thrift for a HBase adapter I&#039;m planning to write, but found a few other interesting topics as well. They have given me some ideas for my own blog as well.</description>
		<content:encoded><![CDATA[<p>I am leaning toward disagreement about the parse method. Passing the subject of the parsing really doesn&#8217;t constitute a stateful interface in its current form (the method might as well have been defined as static). But lets say the parsing is a more involves process, that does require certain instance variables. Wouldn&#8217;t it then be more appropriate to &#8220;encapsulate the concept that varies&#8221;, and create a &#8220;PersonNameParser&#8221;? In fact, I think that would be more appropriate in any case, unless you intend the parsed name to be the default output (merged with &#8220;getFullName&#8221;).</p>
<p>My point is that I think it defeats the purpose of a domain object to request operations on the state of that same object. Actually I think you&#8217;ve done the exact opposite of Tell Don&#8217;t Ask. Tell Don&#8217;t Ask doesn&#8217;t mean &#8220;pass arguments instead of using internal state&#8221;, it means &#8220;decisions based entirely upon the state of one object should be made &#8216;inside&#8217; the object itself&#8221;. And in trying to improve testability you actually violated that and broke encapsulation. Because the decision of what to use an argument to explode() has effectively been delegated to the client.</p>
<p>Sure, one should try to keep to the Law of Demeter to avoid &#8220;train wrecks&#8221; and improve cohesion on a package or application level, but I don&#8217;t think that extends to methods used within the same class to fetch internal state.</p>
<p>On a side note I think you have very nice blog here. I came across it when looking for info about Thrift for a HBase adapter I&#8217;m planning to write, but found a few other interesting topics as well. They have given me some ideas for my own blog as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Herman Radtke</title>
		<link>http://www.hermanradtke.com/blog/unit-testing-and-the-law-of-demeter/comment-page-1/#comment-3177</link>
		<dc:creator>Herman Radtke</dc:creator>
		<pubDate>Sun, 17 Jan 2010 20:10:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.hermanradtke.com/blog/?p=287#comment-3177</guid>
		<description>The parseFullName method was a simple example,  not something I was actually working on.  It is obviously much more complicated than just splitting on spaces and thus, facilitates the need for unit testing this method.

I think the above idea applies best to methods that do some business logic like calculate or parse something.  Even if the method is part of a large, highly coupled class, we can still tell the method what to parse/calculate/etc rather than let it ask.  But there is obviously a trade off here: now something must know what to pass into that method.  No problem If there is a service layer, but as you mention, most people just slap code in a controller and move on.

Maybe I will write another post showing how a service layer facilitates good design, which implicitly helps unit testing.</description>
		<content:encoded><![CDATA[<p>The parseFullName method was a simple example,  not something I was actually working on.  It is obviously much more complicated than just splitting on spaces and thus, facilitates the need for unit testing this method.</p>
<p>I think the above idea applies best to methods that do some business logic like calculate or parse something.  Even if the method is part of a large, highly coupled class, we can still tell the method what to parse/calculate/etc rather than let it ask.  But there is obviously a trade off here: now something must know what to pass into that method.  No problem If there is a service layer, but as you mention, most people just slap code in a controller and move on.</p>
<p>Maybe I will write another post showing how a service layer facilitates good design, which implicitly helps unit testing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miles Johnson</title>
		<link>http://www.hermanradtke.com/blog/unit-testing-and-the-law-of-demeter/comment-page-1/#comment-3176</link>
		<dc:creator>Miles Johnson</dc:creator>
		<pubDate>Sun, 17 Jan 2010 19:56:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.hermanradtke.com/blog/?p=287#comment-3176</guid>
		<description>Nice post and easily understandable when it comes to unit testing. However, it seems this theory won&#039;t really apply to applications that aren&#039;t specifically low/loose coupled (Like most large web applications).

Also, when using parseFullName() in actuality, just seems it would be a lot longer to write. I guess it depends on the context of how you will be using it in your app.

$name = $this-&gt;parseFullName($this-&gt;getFullName());</description>
		<content:encoded><![CDATA[<p>Nice post and easily understandable when it comes to unit testing. However, it seems this theory won&#8217;t really apply to applications that aren&#8217;t specifically low/loose coupled (Like most large web applications).</p>
<p>Also, when using parseFullName() in actuality, just seems it would be a lot longer to write. I guess it depends on the context of how you will be using it in your app.</p>
<p>$name = $this-&gt;parseFullName($this-&gt;getFullName());</p>
]]></content:encoded>
	</item>
</channel>
</rss>
