<?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: Anonymous Types In C# Are A Crippled Hack</title>
	<atom:link href="http://lostechies.com/derickbailey/2010/04/14/anonymous-types-in-c-are-a-crippled-hack/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/derickbailey/2010/04/14/anonymous-types-in-c-are-a-crippled-hack/</link>
	<description>Better Than Yesterday</description>
	<lastBuildDate>Fri, 24 May 2013 06:39:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: .Net Training in Chennai</title>
		<link>http://lostechies.com/derickbailey/2010/04/14/anonymous-types-in-c-are-a-crippled-hack/#comment-2979</link>
		<dc:creator>.Net Training in Chennai</dc:creator>
		<pubDate>Wed, 16 Jan 2013 05:48:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/14/anonymous-types-in-c-are-a-crippled-hack.aspx#comment-2979</guid>
		<description>Yes, we need full fledged anonymous types</description>
		<content:encoded><![CDATA[<p>Yes, we need full fledged anonymous types</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dan</title>
		<link>http://lostechies.com/derickbailey/2010/04/14/anonymous-types-in-c-are-a-crippled-hack/#comment-2497</link>
		<dc:creator>dan</dc:creator>
		<pubDate>Wed, 30 May 2012 21:29:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/14/anonymous-types-in-c-are-a-crippled-hack.aspx#comment-2497</guid>
		<description>I&#039;ve coded much in both C# and Java, and I really prefer Java&#039;s anonymous classes. They&#039;re much more powerful, they allow you to have clearly defined shared data between methods of a protocol unlike the &quot;closures everywhere&quot; and &quot;a separate decoupled delegate class for each little action&quot; hack of C#. Say I need to load data from disk in a separate thread and then &quot;finalize/complete&quot; it in another thread (the underlying library is thread-unsafe). In Java I create an abstract class with two abstract methods &quot;executeAsync&quot; and &quot;complete&quot;. Then I can create an anonymous class where method &quot;executeAsync&quot; stores its results inside a shared field, which &quot;complete&quot; later picks on. In C# I would need to create two absolutely separate delegate types, then instantiate two delegates, and the only data they can sure are closured method variables, which is pretty dangerous because C# doesn&#039;t have a &quot;final&quot; constraint on closures like in Java and there can be data mismatch if you change the variable somewhere. Bugs, bugs everywhere. But of course for simple GUI, C#&#039;s delegates are good. The funny thing is that delegate-based GUI programming is outdated and they&#039;re moving to declarative WPF etc. now, so C#&#039;s delegates aren&#039;t that needed anymore.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve coded much in both C# and Java, and I really prefer Java&#8217;s anonymous classes. They&#8217;re much more powerful, they allow you to have clearly defined shared data between methods of a protocol unlike the &#8220;closures everywhere&#8221; and &#8220;a separate decoupled delegate class for each little action&#8221; hack of C#. Say I need to load data from disk in a separate thread and then &#8220;finalize/complete&#8221; it in another thread (the underlying library is thread-unsafe). In Java I create an abstract class with two abstract methods &#8220;executeAsync&#8221; and &#8220;complete&#8221;. Then I can create an anonymous class where method &#8220;executeAsync&#8221; stores its results inside a shared field, which &#8220;complete&#8221; later picks on. In C# I would need to create two absolutely separate delegate types, then instantiate two delegates, and the only data they can sure are closured method variables, which is pretty dangerous because C# doesn&#8217;t have a &#8220;final&#8221; constraint on closures like in Java and there can be data mismatch if you change the variable somewhere. Bugs, bugs everywhere. But of course for simple GUI, C#&#8217;s delegates are good. The funny thing is that delegate-based GUI programming is outdated and they&#8217;re moving to declarative WPF etc. now, so C#&#8217;s delegates aren&#8217;t that needed anymore.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gusman_Bjork</title>
		<link>http://lostechies.com/derickbailey/2010/04/14/anonymous-types-in-c-are-a-crippled-hack/#comment-1711</link>
		<dc:creator>Gusman_Bjork</dc:creator>
		<pubDate>Mon, 08 Aug 2011 03:41:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/14/anonymous-types-in-c-are-a-crippled-hack.aspx#comment-1711</guid>
		<description>        void CreateDinaClass()
        {
 
            var dinaclass = new
            {
 
                DoThis = new Func(s =&gt; int.Parse(s)),
                DoThat = new Func
                    ((a, b) =&gt; 
                        {
 
                            if(a  45)
                                System.Windows.Forms.MessageBox.Show(&quot;Oh god!!!!&quot;);
 
                            return a + b;
 
                        }
                    )
 
            };
 
            UseDinaClass(dinaclass);
        
        }
 
        void UseDinaClass(dynamic AnonClass)
        {
 
            AnonClass.DoThis(&quot;33&quot;);
            AnonClass.DoThat(12,89);
        
        }
So, doesn&#039;t this works like a Java anonymous class?There&#039;s no need for an interface with the dynamic keyword and witha multiline lambda expression a function can be created.I know it&#039;s an old post but I wanted to show this way of creatinganonymous classes with a very similar functionality to Java anonymousclasses.I hate the anonymous classes in Java, i had to program during two yearswith it and really hated the inner classes. And that&#039;s not because C#doesn&#039;t have them, it&#039;s because the readability of the code gets killed.In a function where you hook to multiple events, the code becomes a truly mess which nobody can read without struggling his brain.</description>
		<content:encoded><![CDATA[<p>        void CreateDinaClass()<br />
        {</p>
<p>            var dinaclass = new<br />
            {</p>
<p>                DoThis = new Func(s =&gt; int.Parse(s)),<br />
                DoThat = new Func<br />
                    ((a, b) =&gt; <br />
                        {<br />
 <br />
                            if(a  45)<br />
                                System.Windows.Forms.MessageBox.Show(&#8220;Oh god!!!!&#8221;);</p>
<p>                            return a + b;</p>
<p>                        }<br />
                    )</p>
<p>            };</p>
<p>            UseDinaClass(dinaclass);<br />
        <br />
        }</p>
<p>        void UseDinaClass(dynamic AnonClass)<br />
        {</p>
<p>            AnonClass.DoThis(&#8220;33&#8243;);<br />
            AnonClass.DoThat(12,89);<br />
        <br />
        }<br />
So, doesn&#8217;t this works like a Java anonymous class?There&#8217;s no need for an interface with the dynamic keyword and witha multiline lambda expression a function can be created.I know it&#8217;s an old post but I wanted to show this way of creatinganonymous classes with a very similar functionality to Java anonymousclasses.I hate the anonymous classes in Java, i had to program during two yearswith it and really hated the inner classes. And that&#8217;s not because C#doesn&#8217;t have them, it&#8217;s because the readability of the code gets killed.In a function where you hook to multiple events, the code becomes a truly mess which nobody can read without struggling his brain.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Riley</title>
		<link>http://lostechies.com/derickbailey/2010/04/14/anonymous-types-in-c-are-a-crippled-hack/#comment-809</link>
		<dc:creator>Ryan Riley</dc:creator>
		<pubDate>Wed, 21 Apr 2010 16:12:54 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/14/anonymous-types-in-c-are-a-crippled-hack.aspx#comment-809</guid>
		<description>I think the conclusion here is, F# ftw. That said, while you can&#039;t do interface or class instantiation, you can mimic anonymous methods within anonymous types by using delegate properties. Yes, I know that&#039;s still not the same, but it gets you closer.

With the Reactive Extensions release, I see more people wanting to move to the Observable pattern, and that will likely have us wanting a lot of these features in C#.</description>
		<content:encoded><![CDATA[<p>I think the conclusion here is, F# ftw. That said, while you can&#8217;t do interface or class instantiation, you can mimic anonymous methods within anonymous types by using delegate properties. Yes, I know that&#8217;s still not the same, but it gets you closer.</p>
<p>With the Reactive Extensions release, I see more people wanting to move to the Observable pattern, and that will likely have us wanting a lot of these features in C#.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: derick.bailey</title>
		<link>http://lostechies.com/derickbailey/2010/04/14/anonymous-types-in-c-are-a-crippled-hack/#comment-808</link>
		<dc:creator>derick.bailey</dc:creator>
		<pubDate>Fri, 16 Apr 2010 18:15:48 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/14/anonymous-types-in-c-are-a-crippled-hack.aspx#comment-808</guid>
		<description>@MM - ok, yeah. it was the word &quot;seen&quot; that sparked that response. i see your point now.</description>
		<content:encoded><![CDATA[<p>@MM &#8211; ok, yeah. it was the word &#8220;seen&#8221; that sparked that response. i see your point now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MM</title>
		<link>http://lostechies.com/derickbailey/2010/04/14/anonymous-types-in-c-are-a-crippled-hack/#comment-807</link>
		<dc:creator>MM</dc:creator>
		<pubDate>Fri, 16 Apr 2010 18:10:21 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/14/anonymous-types-in-c-are-a-crippled-hack.aspx#comment-807</guid>
		<description>@derick

no, no, no. that&#039;s not what i&#039;m saying at all. i&#039;m saying what you&#039;re saying. i don&#039;t think anyone was unclear on the difference between the language constructs. we were unclear on what problem it was trying to solve. i actually chose the word &quot;seen&quot; very deliberately in my post above. because that gets right to the point. the question we were all asking is &quot;why do you want this thing?&quot; not &quot;what is this thing that you want?&quot; 

hope that clears it up (it made so much sense in my head). sorry for the confusion</description>
		<content:encoded><![CDATA[<p>@derick</p>
<p>no, no, no. that&#8217;s not what i&#8217;m saying at all. i&#8217;m saying what you&#8217;re saying. i don&#8217;t think anyone was unclear on the difference between the language constructs. we were unclear on what problem it was trying to solve. i actually chose the word &#8220;seen&#8221; very deliberately in my post above. because that gets right to the point. the question we were all asking is &#8220;why do you want this thing?&#8221; not &#8220;what is this thing that you want?&#8221; </p>
<p>hope that clears it up (it made so much sense in my head). sorry for the confusion</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: derick.bailey</title>
		<link>http://lostechies.com/derickbailey/2010/04/14/anonymous-types-in-c-are-a-crippled-hack/#comment-806</link>
		<dc:creator>derick.bailey</dc:creator>
		<pubDate>Fri, 16 Apr 2010 17:58:27 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/14/anonymous-types-in-c-are-a-crippled-hack.aspx#comment-806</guid>
		<description>@MM

I own two compact cars (one for me, one for my wife). I have to rent a truck every time I want to buy anything larger than half a cubic meter. what you&#039;re saying is that i shouldn&#039;t wish my car was bigger when i need to buy something that won&#039;t fit in it... that i shouldn&#039;t want to a bigger vehicle so that i can be larger things. 

you&#039;ve only ever seen your neighbor drive himself to work... is that because that&#039;s all he ever does? or is that because that&#039;s all his car will let him do? perhaps there are times when your neighbor really needed a large van, but only had a compact car and therefore was only able to drive to work instead of being able to do all the things a large van would let them do.

... don&#039;t confuse &quot;can&#039;t&quot; with &quot;don&#039;t need to&quot;.</description>
		<content:encoded><![CDATA[<p>@MM</p>
<p>I own two compact cars (one for me, one for my wife). I have to rent a truck every time I want to buy anything larger than half a cubic meter. what you&#8217;re saying is that i shouldn&#8217;t wish my car was bigger when i need to buy something that won&#8217;t fit in it&#8230; that i shouldn&#8217;t want to a bigger vehicle so that i can be larger things. </p>
<p>you&#8217;ve only ever seen your neighbor drive himself to work&#8230; is that because that&#8217;s all he ever does? or is that because that&#8217;s all his car will let him do? perhaps there are times when your neighbor really needed a large van, but only had a compact car and therefore was only able to drive to work instead of being able to do all the things a large van would let them do.</p>
<p>&#8230; don&#8217;t confuse &#8220;can&#8217;t&#8221; with &#8220;don&#8217;t need to&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MM</title>
		<link>http://lostechies.com/derickbailey/2010/04/14/anonymous-types-in-c-are-a-crippled-hack/#comment-805</link>
		<dc:creator>MM</dc:creator>
		<pubDate>Fri, 16 Apr 2010 17:09:20 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/14/anonymous-types-in-c-are-a-crippled-hack.aspx#comment-805</guid>
		<description>@James

My neighbor and I both drive compact cars. The other day we were standing outside and someone drove by in a big van. My neighbor started lamenting about how he wished he had a big van. So I said to my neighbor, &quot;Neighbor, the only thing I&#039;ve ever seen you use your compact car for is driving yourself, and only yourself, to work. Why would you need a big van?&quot;

Please note that I did not ask him to explain the difference between a compact car and a big van.</description>
		<content:encoded><![CDATA[<p>@James</p>
<p>My neighbor and I both drive compact cars. The other day we were standing outside and someone drove by in a big van. My neighbor started lamenting about how he wished he had a big van. So I said to my neighbor, &#8220;Neighbor, the only thing I&#8217;ve ever seen you use your compact car for is driving yourself, and only yourself, to work. Why would you need a big van?&#8221;</p>
<p>Please note that I did not ask him to explain the difference between a compact car and a big van.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Esteban</title>
		<link>http://lostechies.com/derickbailey/2010/04/14/anonymous-types-in-c-are-a-crippled-hack/#comment-804</link>
		<dc:creator>Esteban</dc:creator>
		<pubDate>Fri, 16 Apr 2010 09:45:31 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/14/anonymous-types-in-c-are-a-crippled-hack.aspx#comment-804</guid>
		<description>@James:
Sometimes when you&#039;ve stated a dependency on an interface but really only depended on a single method&#039;s declaration from that interface, you probably exaggerated your needs. 

Got that?

Of course, as a consumer of such a stupid class, the functionality you suggest is desperately wanted.

By the way, why are you so angry?</description>
		<content:encoded><![CDATA[<p>@James:<br />
Sometimes when you&#8217;ve stated a dependency on an interface but really only depended on a single method&#8217;s declaration from that interface, you probably exaggerated your needs. </p>
<p>Got that?</p>
<p>Of course, as a consumer of such a stupid class, the functionality you suggest is desperately wanted.</p>
<p>By the way, why are you so angry?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://lostechies.com/derickbailey/2010/04/14/anonymous-types-in-c-are-a-crippled-hack/#comment-803</link>
		<dc:creator>James</dc:creator>
		<pubDate>Thu, 15 Apr 2010 21:51:46 +0000</pubDate>
		<guid isPermaLink="false">/blogs/derickbailey/archive/2010/04/14/anonymous-types-in-c-are-a-crippled-hack.aspx#comment-803</guid>
		<description>Sigh.

Depressing that so many people miss the point. You cannot do a method-inline implementation in C#. You can in Java.

Some times, for interfaces with 2 or 3 methods, it would be real handy to be able to implement it inline in C#. But you can&#039;t. You can in Java.

Support for delegates is not the same thing.

Can you implement an interface inline in C#? No, you can&#039;t. But in Java you can.

Got that? 

Idiots.

(9-year MS developer, but that doesn&#039;t cause me to turn off my brain).</description>
		<content:encoded><![CDATA[<p>Sigh.</p>
<p>Depressing that so many people miss the point. You cannot do a method-inline implementation in C#. You can in Java.</p>
<p>Some times, for interfaces with 2 or 3 methods, it would be real handy to be able to implement it inline in C#. But you can&#8217;t. You can in Java.</p>
<p>Support for delegates is not the same thing.</p>
<p>Can you implement an interface inline in C#? No, you can&#8217;t. But in Java you can.</p>
<p>Got that? </p>
<p>Idiots.</p>
<p>(9-year MS developer, but that doesn&#8217;t cause me to turn off my brain).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
