tag:blogger.com,1999:blog-3761674922653685009.post4686361392172967805..comments2023-11-05T03:40:13.874-08:00Comments on unfold: Silverlight and Anonymous Types: A Cautionary TaleJafar Husainhttp://www.blogger.com/profile/15444397760399385108noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-3761674922653685009.post-80285903780281839652009-08-03T01:15:35.515-07:002009-08-03T01:15:35.515-07:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3761674922653685009.post-39441962254643225592009-08-03T01:15:12.404-07:002009-08-03T01:15:12.404-07:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3761674922653685009.post-80551145173984065332009-07-27T19:23:26.086-07:002009-07-27T19:23:26.086-07:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3761674922653685009.post-12609033816993650162009-07-27T19:23:19.168-07:002009-07-27T19:23:19.168-07:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3761674922653685009.post-43265874796145670022009-06-27T21:16:57.204-07:002009-06-27T21:16:57.204-07:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3761674922653685009.post-35107985029210036752009-05-13T01:37:00.000-07:002009-05-13T01:37:00.000-07:00This comment has been removed by a blog administrator.Affordable Luxurious Wedding Dress Bloghttps://www.blogger.com/profile/05027988606340777687noreply@blogger.comtag:blogger.com,1999:blog-3761674922653685009.post-69739039070927459892009-02-06T18:07:00.000-08:002009-02-06T18:07:00.000-08:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3761674922653685009.post-2456859440051589992008-11-14T14:38:00.000-08:002008-11-14T14:38:00.000-08:00I never trusted those anonymous types.hmm, should ...I never trusted those anonymous types.<BR/><BR/>hmm, should i sign this as anonymous?bryanhttps://www.blogger.com/profile/01332614158223702009noreply@blogger.comtag:blogger.com,1999:blog-3761674922653685009.post-68426443617773320312008-10-27T12:58:00.000-07:002008-10-27T12:58:00.000-07:00ashmind: You're quite correct that if you're caref...ashmind: You're quite correct that if you're careful with query comprehensions you can avoid generating anonymous types. This advice is really just a precaution.<BR/><BR/>Your concerns about the readability are very real. I'm personally a huge advocate of pushing as much semantic information into the code as possible. I assure you it pains me to have to relegate this information to a comment. That is the price we have to pay for keeping executable size down though.<BR/><BR/>Unfortunately avoiding projections is not so easy. They are a key part of functional programming. In the admittedly contrived example I provided there doesn't appear to be a reason to use them. However sometimes you want to process data and project the result into a tuple. It's a good idea in such cases to do as much processing as you can in the stream generation as opposed to the stream traversal (i.e. the foreach statement). The reason for this is that it exposes more computation that can be done in Parallel. Think technologies like PLinq.Jafar Husainhttps://www.blogger.com/profile/15444397760399385108noreply@blogger.comtag:blogger.com,1999:blog-3761674922653685009.post-58288331172040122172008-10-27T07:54:00.000-07:002008-10-27T07:54:00.000-07:00Great to have you back!I had a chance, recently, t...Great to have you back!<BR/><BR/>I had a chance, recently, to use some of the ideas you suggested in the following post:<BR/><BR/>http://themechanicalbride.blogspot.com/2007/02/do-you-know-linq-fu.html<BR/><BR/>I have been doing software for a pretty long time. The "LINQ to Code" listing is possibly the most beautiful code I have ever seen.<BR/><BR/>It was like reading poetry :)<BR/><BR/>Thanks!Unknownhttps://www.blogger.com/profile/08256620049194284908noreply@blogger.comtag:blogger.com,1999:blog-3761674922653685009.post-33994158689292978382008-10-25T02:03:00.000-07:002008-10-25T02:03:00.000-07:00I do see the problem, but I disagree with suggesti...I do see the problem, but I disagree with suggestions.<BR/><BR/>As far as I remember, only 'let' introduces invisible anonymus type, and it is easy to avoid let if you know this. So avoiding the query syntax altogether is an overkill.<BR/><BR/>And tuples are hard to understand, even three lines down from the creating code. Because what exactly is x.First? Not easy to remember.<BR/><BR/>I would just say 'avoid projections'.<BR/><BR/>var types = this.GetType().Assembly.GetTypes();<BR/><BR/><BR/>Now you get the full Type instead of the projection, and you haven't lost even a bit of information.<BR/><BR/>If you really need to do a projection and pass the results around, it is a better idea to create a specific type with well-named auto properties.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3761674922653685009.post-32878436421667776762008-10-25T00:27:00.000-07:002008-10-25T00:27:00.000-07:00If this cautionary tale ever gets made into a movi...If this cautionary tale ever gets made into a movie, I bet they'll get someone handsome - and brilliant - to play the role of the tester. :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3761674922653685009.post-43425673602340088412008-10-24T23:47:00.000-07:002008-10-24T23:47:00.000-07:00It's funny that you care about leaneness of the co...It's funny that you care about leaneness of the code and yet you use automatic C# properties for your code.<BR/><BR/>Each of those property will introduce 2 methods + 1 property definition + 1 field. <BR/><BR/>You could have used a single readonly field which would have saved you even more data.<BR/><BR/>Nice post though.Anonymousnoreply@blogger.com