<?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: Flaw: Digging into Collaborators</title>
	<atom:link href="http://misko.hevery.com/code-reviewers-guide/flaw-digging-into-collaborators/feed/" rel="self" type="application/rss+xml" />
	<link>http://misko.hevery.com</link>
	<description>Testability Explorer</description>
	<lastBuildDate>Thu, 19 Jan 2012 16:42:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Luke</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-digging-into-collaborators/comment-page-1/#comment-5159</link>
		<dc:creator>Luke</dc:creator>
		<pubDate>Wed, 01 Dec 2010 00:02:29 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=325#comment-5159</guid>
		<description>I wouldn&#039;t worry about objects passed in but not used directly (well, depending on the use case). Take a look at your first concrete example. The Law of Demeter says use no more than one &quot;dot,&quot; so for example:

Instead of:

public Connection getDbConnection(String dbName, String dbPort, String username, String password) {
    return myDb.createConnection(
        dbName,
        dbPort,
        username,
        password);
}

This would be preferred:

public Connection getDbConnection(ConnectionInfo connInfo) {
    return myDb.createConnection(
        connInfo.getDbName(),
        connInfo.getDbPort(),
        connInfo.getUsername(),
        connInfo.getPassword());
}

And in this (fictional) example, creating a ConnectionInfo object during testing is trivial because the ConnectionInfo class is just a bag of properties (model object).

If, later, I need another property, I only have to modify ConnectionInfo and not my method declaration.</description>
		<content:encoded><![CDATA[<p>I wouldn&#8217;t worry about objects passed in but not used directly (well, depending on the use case). Take a look at your first concrete example. The Law of Demeter says use no more than one &#8220;dot,&#8221; so for example:</p>
<p>Instead of:</p>
<p>public Connection getDbConnection(String dbName, String dbPort, String username, String password) {<br />
    return myDb.createConnection(<br />
        dbName,<br />
        dbPort,<br />
        username,<br />
        password);<br />
}</p>
<p>This would be preferred:</p>
<p>public Connection getDbConnection(ConnectionInfo connInfo) {<br />
    return myDb.createConnection(<br />
        connInfo.getDbName(),<br />
        connInfo.getDbPort(),<br />
        connInfo.getUsername(),<br />
        connInfo.getPassword());<br />
}</p>
<p>And in this (fictional) example, creating a ConnectionInfo object during testing is trivial because the ConnectionInfo class is just a bag of properties (model object).</p>
<p>If, later, I need another property, I only have to modify ConnectionInfo and not my method declaration.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Linking to Mi?ko&#8217;s, Russ&#8217; and my Testability Guide at JAW Speak</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-digging-into-collaborators/comment-page-1/#comment-3595</link>
		<dc:creator>Linking to Mi?ko&#8217;s, Russ&#8217; and my Testability Guide at JAW Speak</dc:creator>
		<pubDate>Tue, 08 Jun 2010 04:59:25 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=325#comment-3595</guid>
		<description>[...] Flaw #2: Digging into Collaborators (link)  [...]</description>
		<content:encoded><![CDATA[<p>[...] Flaw #2: Digging into Collaborators (link)  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Swiss army knife for XP PHP projects (defining code quality) &#124; Alternate Illusion</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-digging-into-collaborators/comment-page-1/#comment-3243</link>
		<dc:creator>Swiss army knife for XP PHP projects (defining code quality) &#124; Alternate Illusion</dc:creator>
		<pubDate>Thu, 25 Mar 2010 17:50:23 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=325#comment-3243</guid>
		<description>[...] Flaw #2: Digging into Collaborators [...]</description>
		<content:encoded><![CDATA[<p>[...] Flaw #2: Digging into Collaborators [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niceboomer and the future of changes &#187; Blog Archive &#187; Guide: Writing Testable Code</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-digging-into-collaborators/comment-page-1/#comment-3069</link>
		<dc:creator>Niceboomer and the future of changes &#187; Blog Archive &#187; Guide: Writing Testable Code</dc:creator>
		<pubDate>Fri, 12 Feb 2010 20:51:46 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=325#comment-3069</guid>
		<description>[...] Flaw #2: Digging into Collaborators [...]</description>
		<content:encoded><![CDATA[<p>[...] Flaw #2: Digging into Collaborators [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Einführung in TDD &#38; Clean Code Talks &#124; geekcloud.org</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-digging-into-collaborators/comment-page-1/#comment-2427</link>
		<dc:creator>Einführung in TDD &#38; Clean Code Talks &#124; geekcloud.org</dc:creator>
		<pubDate>Sun, 22 Nov 2009 14:50:55 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=325#comment-2427</guid>
		<description>[...] Flaw #2: Digging into Collaborators [...]</description>
		<content:encoded><![CDATA[<p>[...] Flaw #2: Digging into Collaborators [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rafael Naufal</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-digging-into-collaborators/comment-page-1/#comment-614</link>
		<dc:creator>Rafael Naufal</dc:creator>
		<pubDate>Fri, 23 Jan 2009 16:00:06 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=325#comment-614</guid>
		<description>Great post, Misko. It helps a lot improving the code design by showing the problems of not passing explicitly the objects to methods or constructors.&#160; Just one remark: In the &quot;Problem: Law of Demeter Violated to Inappropriately make a Service Locator&quot; section,&#160; there&#039;s no assignment to the Lock member variable at the UpdateBug constructor.</description>
		<content:encoded><![CDATA[<p>Great post, Misko. It helps a lot improving the code design by showing the problems of not passing explicitly the objects to methods or constructors.&nbsp; Just one remark: In the &#8220;Problem: Law of Demeter Violated to Inappropriately make a Service Locator&#8221; section,&nbsp; there&#8217;s no assignment to the Lock member variable at the UpdateBug constructor.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Guide to Writing Testable Code / CODEISPOETRY</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-digging-into-collaborators/comment-page-1/#comment-461</link>
		<dc:creator>Guide to Writing Testable Code / CODEISPOETRY</dc:creator>
		<pubDate>Thu, 11 Dec 2008 01:38:01 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=325#comment-461</guid>
		<description>[...] Flaw #2: Digging into Collaborators [...]</description>
		<content:encoded><![CDATA[<p>[...] Flaw #2: Digging into Collaborators [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vlad</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-digging-into-collaborators/comment-page-1/#comment-415</link>
		<dc:creator>Vlad</dc:creator>
		<pubDate>Fri, 28 Nov 2008 10:02:36 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=325#comment-415</guid>
		<description>Hi!
I enjoy your posts and I&#039;ve been inspired to add more test to my code. 

My question is if it is a flaw or not if one method has an argument that is both used directly and also to access some sub-object.

For example in the LoginPage, if login() needs both the client and the authenticator, is it okay to just send the client as a parameter, or should one send both client and authenticator?

best regards,
Vlad</description>
		<content:encoded><![CDATA[<p>Hi!<br />
I enjoy your posts and I&#8217;ve been inspired to add more test to my code. </p>
<p>My question is if it is a flaw or not if one method has an argument that is both used directly and also to access some sub-object.</p>
<p>For example in the LoginPage, if login() needs both the client and the authenticator, is it okay to just send the client as a parameter, or should one send both client and authenticator?</p>
<p>best regards,<br />
Vlad</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Guide to Writing Testable Code &#124; Miško Hevery</title>
		<link>http://misko.hevery.com/code-reviewers-guide/flaw-digging-into-collaborators/comment-page-1/#comment-389</link>
		<dc:creator>Guide to Writing Testable Code &#124; Miško Hevery</dc:creator>
		<pubDate>Wed, 26 Nov 2008 18:04:00 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?page_id=325#comment-389</guid>
		<description>[...] Flaw #2: Digging into Collaborators [...]</description>
		<content:encoded><![CDATA[<p>[...] Flaw #2: Digging into Collaborators [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

