<?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: Constructor Chaining</title>
	<atom:link href="http://www.csharp411.com/constructor-chaining/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.csharp411.com/constructor-chaining/</link>
	<description>C# Development</description>
	<lastBuildDate>Fri, 03 Feb 2012 11:14:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Akash</title>
		<link>http://www.csharp411.com/constructor-chaining/#comment-538</link>
		<dc:creator>Akash</dc:creator>
		<pubDate>Mon, 26 Sep 2011 08:16:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/constructor-chaining/#comment-538</guid>
		<description>Nice article .. you can find more on

http://dotnetdrives.blogspot.com/2011/09/constructor-chainingin-csharp.html</description>
		<content:encoded><![CDATA[<p>Nice article .. you can find more on</p>
<p><a href="http://dotnetdrives.blogspot.com/2011/09/constructor-chainingin-csharp.html" rel="nofollow">http://dotnetdrives.blogspot.com/2011/09/constructor-chainingin-csharp.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: manoj</title>
		<link>http://www.csharp411.com/constructor-chaining/#comment-537</link>
		<dc:creator>manoj</dc:creator>
		<pubDate>Sun, 19 Jun 2011 18:07:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/constructor-chaining/#comment-537</guid>
		<description>good concept but i wana little bit more</description>
		<content:encoded><![CDATA[<p>good concept but i wana little bit more</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Announcing: TinyIoC &#8211; An Easy to Use, Hassle Free, Inversion of Control Container &#124; GrumpyDev</title>
		<link>http://www.csharp411.com/constructor-chaining/#comment-536</link>
		<dc:creator>Announcing: TinyIoC &#8211; An Easy to Use, Hassle Free, Inversion of Control Container &#124; GrumpyDev</dc:creator>
		<pubDate>Tue, 02 Mar 2010 06:58:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/constructor-chaining/#comment-536</guid>
		<description>[...] Whenever I start a new “pet” project I usually *want* to use IoC, but I don’t really want the hassle of taking a dependency on a container, or adding another binary to my project. Usually this leaves me using “poor man’s IoC”, whereby I define dependencies in my constructors, but I pass them in manually or construct them using constructor chaining. [...] </description>
		<content:encoded><![CDATA[<p>[...] Whenever I start a new “pet” project I usually *want* to use IoC, but I don’t really want the hassle of taking a dependency on a container, or adding another binary to my project. Usually this leaves me using “poor man’s IoC”, whereby I define dependencies in my constructors, but I pass them in manually or construct them using constructor chaining. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: timm</title>
		<link>http://www.csharp411.com/constructor-chaining/#comment-535</link>
		<dc:creator>timm</dc:creator>
		<pubDate>Fri, 24 Apr 2009 13:55:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/constructor-chaining/#comment-535</guid>
		<description>Re: Is it a problem for a performance point of view?

No.  You&#039;re not likely to notice any performance difference unless you are looping billions of times.

Typically with C# you don&#039;t want to waste much time micro-optimizing.  In other words, just write the code you want and don&#039;t worry too much about performance.  Then once you have the code working the way you want it, if you notice any performance issues, use a profiler to identify trouble spots, then optimize the slow sections of code as necessary.</description>
		<content:encoded><![CDATA[<p>Re: Is it a problem for a performance point of view?</p>
<p>No.  You&#8217;re not likely to notice any performance difference unless you are looping billions of times.</p>
<p>Typically with C# you don&#8217;t want to waste much time micro-optimizing.  In other words, just write the code you want and don&#8217;t worry too much about performance.  Then once you have the code working the way you want it, if you notice any performance issues, use a profiler to identify trouble spots, then optimize the slow sections of code as necessary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Rex</title>
		<link>http://www.csharp411.com/constructor-chaining/#comment-534</link>
		<dc:creator>Charles Rex</dc:creator>
		<pubDate>Thu, 23 Apr 2009 18:55:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/constructor-chaining/#comment-534</guid>
		<description>Hello,


1) I would like to chain constructors as shown below, 
because in this way all the initialization logic is in just one place

private Test( bool a, int b )
  : this( a, b, &quot;&quot;, -1 )

{
}

public Test( bool a, int b, string c )
    : this( a, b, c, -1 )
{
}

public Test( bool a, int b, float d )
    : this( a, b, &quot;&quot;, d )
{
}
public Test( bool a, int b, string c, float d )
{
    this.m_A = a;
    this.m_B = b;
    this.m_C = c;
    this.m_D = d;

}

2) I would like only the last constructor (with 4 parameters) to look like below:

Is it a problem for a performance point of view ?

public Test( bool a, int b, string c, float d )
{
    Initialize(a, b, c, d);
}

public Initialize( bool a, int b, string c, float d )
{
    this.m_A = a;
    this.m_B = b;
    this.m_C = c;
    this.m_D = d;

}</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>1) I would like to chain constructors as shown below,<br />
because in this way all the initialization logic is in just one place</p>
<p>private Test( bool a, int b )<br />
  : this( a, b, &#8220;&#8221;, -1 )</p>
<p>{<br />
}</p>
<p>public Test( bool a, int b, string c )<br />
    : this( a, b, c, -1 )<br />
{<br />
}</p>
<p>public Test( bool a, int b, float d )<br />
    : this( a, b, &#8220;&#8221;, d )<br />
{<br />
}<br />
public Test( bool a, int b, string c, float d )<br />
{<br />
    this.m_A = a;<br />
    this.m_B = b;<br />
    this.m_C = c;<br />
    this.m_D = d;</p>
<p>}</p>
<p>2) I would like only the last constructor (with 4 parameters) to look like below:</p>
<p>Is it a problem for a performance point of view ?</p>
<p>public Test( bool a, int b, string c, float d )<br />
{<br />
    Initialize(a, b, c, d);<br />
}</p>
<p>public Initialize( bool a, int b, string c, float d )<br />
{<br />
    this.m_A = a;<br />
    this.m_B = b;<br />
    this.m_C = c;<br />
    this.m_D = d;</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: phenry</title>
		<link>http://www.csharp411.com/constructor-chaining/#comment-533</link>
		<dc:creator>phenry</dc:creator>
		<pubDate>Thu, 23 Apr 2009 14:02:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/constructor-chaining/#comment-533</guid>
		<description>I agree with timm, keeping things DRY (Don&#039;t Repeat Yourself) sometimes means refactoring things out of constructors into your own methods.  Nothing wrong with it, especially since you have the F12 in Visual Studio to follow the method chain. :&gt;</description>
		<content:encoded><![CDATA[<p>I agree with timm, keeping things DRY (Don&#8217;t Repeat Yourself) sometimes means refactoring things out of constructors into your own methods.  Nothing wrong with it, especially since you have the F12 in Visual Studio to follow the method chain. :&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: timm</title>
		<link>http://www.csharp411.com/constructor-chaining/#comment-532</link>
		<dc:creator>timm</dc:creator>
		<pubDate>Thu, 23 Apr 2009 13:35:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/constructor-chaining/#comment-532</guid>
		<description>Charles, if I understand your question correctly, in your case you would call the Initialize method from your constructor so as not to duplicate the initialization code in your constructor and in the Initialize method.  Although constructor chaining is preferred, you have an overriding requirement.</description>
		<content:encoded><![CDATA[<p>Charles, if I understand your question correctly, in your case you would call the Initialize method from your constructor so as not to duplicate the initialization code in your constructor and in the Initialize method.  Although constructor chaining is preferred, you have an overriding requirement.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Rex</title>
		<link>http://www.csharp411.com/constructor-chaining/#comment-531</link>
		<dc:creator>Charles Rex</dc:creator>
		<pubDate>Thu, 23 Apr 2009 11:34:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/constructor-chaining/#comment-531</guid>
		<description>Hello,

Allow me one question please:

- Once a Test object is created,  I feel there&#039;s a need for a method like this:
   Initialize(a,b, c) 

    Test test = new Test(true,2,&quot;3&quot;);

    test.Initialize(false,8,&quot;9&quot;);
    test.Initialize(true,10,&quot;11&quot;);


How would you write the Initialize method in order to avoid copy paste code from the constructor ??

 public Initialize( bool a, int b, string c )
 {
    this.m_A = a;
    this.m_B = b;
    this.m_C = c;
}</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>Allow me one question please:</p>
<p>- Once a Test object is created,  I feel there&#8217;s a need for a method like this:<br />
   Initialize(a,b, c) </p>
<p>    Test test = new Test(true,2,&#8221;3&#8243;);</p>
<p>    test.Initialize(false,8,&#8221;9&#8243;);<br />
    test.Initialize(true,10,&#8221;11&#8243;);</p>
<p>How would you write the Initialize method in order to avoid copy paste code from the constructor ??</p>
<p> public Initialize( bool a, int b, string c )<br />
 {<br />
    this.m_A = a;<br />
    this.m_B = b;<br />
    this.m_C = c;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PHenry</title>
		<link>http://www.csharp411.com/constructor-chaining/#comment-530</link>
		<dc:creator>PHenry</dc:creator>
		<pubDate>Thu, 28 Aug 2008 14:01:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/constructor-chaining/#comment-530</guid>
		<description>Great example, I&#039;ve linked to your example from an article I wrote as well.

http://www.pchenry.com/Home/tabid/36/EntryID/22/Default.aspx</description>
		<content:encoded><![CDATA[<p>Great example, I&#8217;ve linked to your example from an article I wrote as well.</p>
<p><a href="http://www.pchenry.com/Home/tabid/36/EntryID/22/Default.aspx" rel="nofollow">http://www.pchenry.com/Home/tabid/36/EntryID/22/Default.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reflective Perspective - Chris Alcock &#187; The Morning Brew #50</title>
		<link>http://www.csharp411.com/constructor-chaining/#comment-529</link>
		<dc:creator>Reflective Perspective - Chris Alcock &#187; The Morning Brew #50</dc:creator>
		<pubDate>Tue, 11 Mar 2008 08:18:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/constructor-chaining/#comment-529</guid>
		<description>[...] Constructor Chaining - C# 411 shows a nice way of making all your constructors share code. [...] </description>
		<content:encoded><![CDATA[<p>[...] Constructor Chaining &#8211; C# 411 shows a nice way of making all your constructors share code. [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

