<?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: To &#8220;new&#8221; or not to &#8220;new&#8221;&#8230;</title>
	<atom:link href="http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/feed/" rel="self" type="application/rss+xml" />
	<link>http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/</link>
	<description>Testability Explorer</description>
	<lastBuildDate>Thu, 02 Sep 2010 04:05:01 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: misko</title>
		<link>http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/comment-page-1/#comment-3046</link>
		<dc:creator>misko</dc:creator>
		<pubDate>Mon, 08 Feb 2010 02:56:29 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=246#comment-3046</guid>
		<description>@ Juraj,

I would solve this in this way

interface Output;
class Speaker implements Output;
class Headset implements Output;
class OutputSelector(Speaker, Headset) implements Output;
class MusicPlayer(Output);

s = new Speaker()
h = new Headset()
os = new OutputSerector(s, h);
mp = new MusicPlayer(os);

os.seletOutput(...);
wp.play();</description>
		<content:encoded><![CDATA[<p>@ Juraj,</p>
<p>I would solve this in this way</p>
<p>interface Output;<br />
class Speaker implements Output;<br />
class Headset implements Output;<br />
class OutputSelector(Speaker, Headset) implements Output;<br />
class MusicPlayer(Output);</p>
<p>s = new Speaker()<br />
h = new Headset()<br />
os = new OutputSerector(s, h);<br />
mp = new MusicPlayer(os);</p>
<p>os.seletOutput(&#8230;);<br />
wp.play();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Juraj Blahunka</title>
		<link>http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/comment-page-1/#comment-3042</link>
		<dc:creator>Juraj Blahunka</dc:creator>
		<pubDate>Sun, 07 Feb 2010 00:15:55 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=246#comment-3042</guid>
		<description>@Misko What about injectables, that are required for object instantiation but can be changed with another values? (like your MusicPlayer, which needs AudioDevice)... Sure AudioDevice is needed in MusicPlayer&#039;s constructor, but AudioDevice can change (from Speakers to Headset).. Should a SETTER be introduced? Doesn&#039;t this bring ambiguity to the MusicPlayer class?</description>
		<content:encoded><![CDATA[<p>@Misko What about injectables, that are required for object instantiation but can be changed with another values? (like your MusicPlayer, which needs AudioDevice)&#8230; Sure AudioDevice is needed in MusicPlayer&#8217;s constructor, but AudioDevice can change (from Speakers to Headset).. Should a SETTER be introduced? Doesn&#8217;t this bring ambiguity to the MusicPlayer class?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Koen</title>
		<link>http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/comment-page-1/#comment-2623</link>
		<dc:creator>Koen</dc:creator>
		<pubDate>Thu, 17 Dec 2009 17:24:12 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=246#comment-2623</guid>
		<description>A database connection is an injectable. Yet the user credentials are newables. Unless you call db-&gt;connect(credentials). But that&#039;s not really the job of the dependency injection container. So it seems like there are case in which the theory doesn&#039;t hold.</description>
		<content:encoded><![CDATA[<p>A database connection is an injectable. Yet the user credentials are newables. Unless you call db-&gt;connect(credentials). But that&#8217;s not really the job of the dependency injection container. So it seems like there are case in which the theory doesn&#8217;t hold.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: miw</title>
		<link>http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/comment-page-1/#comment-2539</link>
		<dc:creator>miw</dc:creator>
		<pubDate>Fri, 04 Dec 2009 22:29:21 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=246#comment-2539</guid>
		<description>Hi,

@Sam

Good point Sam, I also came to this conclusion and would like to hear about it.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>@Sam</p>
<p>Good point Sam, I also came to this conclusion and would like to hear about it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/comment-page-1/#comment-2494</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Mon, 30 Nov 2009 21:49:51 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=246#comment-2494</guid>
		<description>Hi Misko,
I have a simple question.  Because an injectable can never have a newable as a constructor parameter, at some point there must be an injectable implementation which has a parameterless constructor, right?</description>
		<content:encoded><![CDATA[<p>Hi Misko,<br />
I have a simple question.  Because an injectable can never have a newable as a constructor parameter, at some point there must be an injectable implementation which has a parameterless constructor, right?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Making Zend_Auth more &#8220;Object Oriented&#8221; &#124; Aviblock.com</title>
		<link>http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/comment-page-1/#comment-2226</link>
		<dc:creator>Making Zend_Auth more &#8220;Object Oriented&#8221; &#124; Aviblock.com</dc:creator>
		<pubDate>Fri, 30 Oct 2009 01:13:09 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=246#comment-2226</guid>
		<description>[...] the Zend_Auth_Adapter_Interface. It seems to me that it violates one of Misko&#8217;s rules that injectables can depend on injectables, and newables can depend on newables, but the twain shall not .... So if my understanding of that rule is correct, $adapter-&gt;setIdentity($thisvarisanewable), would [...]</description>
		<content:encoded><![CDATA[<p>[...] the Zend_Auth_Adapter_Interface. It seems to me that it violates one of Misko&#8217;s rules that injectables can depend on injectables, and newables can depend on newables, but the twain shall not &#8230;. So if my understanding of that rule is correct, $adapter-&gt;setIdentity($thisvarisanewable), would [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: All About Google &#187; How to think about OO</title>
		<link>http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/comment-page-1/#comment-2023</link>
		<dc:creator>All About Google &#187; How to think about OO</dc:creator>
		<pubDate>Tue, 06 Oct 2009 06:42:34 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=246#comment-2023</guid>
		<description>[...] Should User have a field reference to Ldap? The answer is no, because you may want to serialize the user to database but you don&#8217;t want to serialize the Ldap. See here. [...]</description>
		<content:encoded><![CDATA[<p>[...] Should User have a field reference to Ldap? The answer is no, because you may want to serialize the user to database but you don&#8217;t want to serialize the Ldap. See here. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marty</title>
		<link>http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/comment-page-1/#comment-1849</link>
		<dc:creator>Marty</dc:creator>
		<pubDate>Thu, 10 Sep 2009 07:04:09 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=246#comment-1849</guid>
		<description>I&#039;m still not really can follow this :(

If your requirements now say that MusicPlayer has to have a name (String field) - it becomes a Newable and its not injectable anymore ?
So what to do with the current MusicPlayer, because it also has the AudioAdvice field - and the injection fails...

what is the solution for that ?</description>
		<content:encoded><![CDATA[<p>I&#8217;m still not really can follow this <img src='http://misko.hevery.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>If your requirements now say that MusicPlayer has to have a name (String field) &#8211; it becomes a Newable and its not injectable anymore ?<br />
So what to do with the current MusicPlayer, because it also has the AudioAdvice field &#8211; and the injection fails&#8230;</p>
<p>what is the solution for that ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Design for Testability and &#8220;Domain-Driven Design&#8221;</title>
		<link>http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/comment-page-1/#comment-779</link>
		<dc:creator>Design for Testability and &#8220;Domain-Driven Design&#8221;</dc:creator>
		<pubDate>Tue, 17 Mar 2009 05:35:10 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=246#comment-779</guid>
		<description>[...] I have a question about your distinction between &#8220;newable&#8221;, value classes and &#8220;injectable&#8221; or &#8220;service&#8221; classes. [...]</description>
		<content:encoded><![CDATA[<p>[...] I have a question about your distinction between &#8220;newable&#8221;, value classes and &#8220;injectable&#8221; or &#8220;service&#8221; classes. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Don Vince</title>
		<link>http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/comment-page-1/#comment-511</link>
		<dc:creator>Don Vince</dc:creator>
		<pubDate>Tue, 30 Dec 2008 14:00:20 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=246#comment-511</guid>
		<description>Great article, I&#039;ve been trying to wrap my head around the subtleties.For a Logger class, an Injectable (a good sell on that can be found here: http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/ ) I can see that all/most the Injectable&#039;s will have the Logger as a constructor parameter and will be merrily logging away to the object.What I&#039;m not sure about is when a newable wants to do it&#039;s logging.I think I could:Put the logger on the signature every method that does some logging (feels ugly)Ensure the newable&#039;s have a fantastic ToString() method and let the Injectable&#039;s do all the logging (feels nicer)Any further suggestions out there?</description>
		<content:encoded><![CDATA[<p>Great article, I&#8217;ve been trying to wrap my head around the subtleties.For a Logger class, an Injectable (a good sell on that can be found here: <a href="http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/" rel="nofollow">http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/</a> ) I can see that all/most the Injectable&#8217;s will have the Logger as a constructor parameter and will be merrily logging away to the object.What I&#8217;m not sure about is when a newable wants to do it&#8217;s logging.I think I could:Put the logger on the signature every method that does some logging (feels ugly)Ensure the newable&#8217;s have a fantastic ToString() method and let the Injectable&#8217;s do all the logging (feels nicer)Any further suggestions out there?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
