tag:blogger.com,1999:blog-6393051114813114443.post3543065393744851957..comments2024-01-24T15:38:09.758-05:00Comments on Lee's Blog: C# 3.0: The Sweet and Sour of Syntactic SugarLee Richardsonhttp://www.blogger.com/profile/01314803491511307042noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-6393051114813114443.post-71349947504342280422008-09-22T09:43:00.000-05:002008-09-22T09:43:00.000-05:00you're a toolyou're a toolAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6393051114813114443.post-51216476488386810792007-05-03T07:09:00.000-05:002007-05-03T07:09:00.000-05:00> HARHAR, please tell me why you use getters and s...> HARHAR, please tell me why you use getters and setters with simply returning and writing the values from the outside to the member var. When you want that you can simply make that property public!<BR/><BR/>You need to use properties for databinding. <BR/><BR/>But, if you are doing databinding, you probably have to decorate the setter anyway and not use this syntax.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6393051114813114443.post-19139245556606661472007-05-02T14:58:00.000-05:002007-05-02T14:58:00.000-05:00i will say .net 3.5 rather than 3.0 that is just ....i will say .net 3.5 rather than 3.0 that is just .net 2.0 + wcf + wpf + wf + csAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6393051114813114443.post-2518281904663461972007-05-02T12:30:00.000-05:002007-05-02T12:30:00.000-05:00Re: Anonymous on May 2:Good point. In my mind the ...Re: Anonymous on May 2:<BR/><BR/>Good point. In my mind the two are so similar I figured no one would mind. For completeness here's the example from Guthrie:<BR/><BR/>List<Person> people = new List<Person> {<BR/> new Person { FirstName = "Scott", LastName = "Guthrie", Age = 32 },<BR/> new Person { FirstName = "Bill", LastName = "Gates", Age = 50 },<BR/> new Person { FirstName = "Susanne", LastName = "Guthrie", Age = 32 }<BR/>};<BR/><BR/>That code combines collection initializers and object initializers. I just think that will be extremely ugly once you initialize those Person objects as in my example, but I do now recognize the benefit of additional structure.Lee Richardsonhttps://www.blogger.com/profile/01314803491511307042noreply@blogger.comtag:blogger.com,1999:blog-6393051114813114443.post-73624308390655939202007-05-02T12:13:00.000-05:002007-05-02T12:13:00.000-05:00Re: anonymous on April 28:The answer to your quest...Re: anonymous on April 28:<BR/><BR/>The answer to your question is in Scott Guthrie's original post. Rather than restate I'll just quote him:<BR/><BR/>"There are a lot of downsides to exposing public fields. Two of the big problems are: 1) you can't easily databind against fields, and 2) if you expose public fields from your classes you can't later change them to properties (for example: to add validation logic to the setters) without recompiling any assemblies compiled against the old class."Lee Richardsonhttps://www.blogger.com/profile/01314803491511307042noreply@blogger.comtag:blogger.com,1999:blog-6393051114813114443.post-60784946914368748132007-05-02T11:45:00.000-05:002007-05-02T11:45:00.000-05:00And where is the "Collection Initializers" example...And where is the "Collection Initializers" example?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6393051114813114443.post-88984536510294066442007-04-28T04:57:00.000-05:002007-04-28T04:57:00.000-05:00HARHAR, please tell me why you use getters and set...HARHAR, please tell me why you use getters and setters with simply returning and writing the values from the outside to the member var. When you want that you can simply make that property public!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6393051114813114443.post-42360340584264680442007-04-26T17:12:00.000-05:002007-04-26T17:12:00.000-05:00I very much appreciate the debate and hearing diff...I very much appreciate the debate and hearing different points of view on the topic. <BR/><BR/>Regarding Scott's post, I'm honored you (he) would post on my humble Blog. I am looking forward to reading the LINQ post, not quite enough time at present; will read and comment later.<BR/><BR/>Mike & John, thank you very much for the link. I actually found the argument in the article compelling. Basically the object initializer and collection initializer syntax groups and *forces* a section of code to be used exclusively for initialization. <BR/><BR/>I also now realize this is what Seth Schroeder was referring to when he said the syntax provides more structure. That was a comment on my double-posted company blog at:<BR/><BR/>http://www.nearinfinity.com/blogs/page/lrichard?entry=c_3_0_the_sweet<BR/><BR/>I still don't buy the arguments of reducing number of lines or eliminating retyping of variable names (that's what intellisence is for), but I sure do like structure in code.<BR/><BR/>And who knows, perhaps with the addition of reading the LINQ post I will be a complete convert.Lee Richardsonhttps://www.blogger.com/profile/01314803491511307042noreply@blogger.comtag:blogger.com,1999:blog-6393051114813114443.post-43616175138669915492007-04-26T16:05:00.000-05:002007-04-26T16:05:00.000-05:00Thank goodness Mike jumped in and posted that link...Thank goodness Mike jumped in and posted that link. I would have wracked my brain for a couple of hours trying to remember where I saw that.Huffhttps://www.blogger.com/profile/17622652320471746903noreply@blogger.comtag:blogger.com,1999:blog-6393051114813114443.post-25279505627513934122007-04-26T15:34:00.000-05:002007-04-26T15:34:00.000-05:00Reg had something different to say about the same ...Reg had something different to say about the same type of syntax:<BR/>http://weblog.raganwald.com/2007/04/rails-style-creators-in-java-or-how-i.html<BR/><BR/>Not the same language, but the principle is the same. He makes good arguments for that style.Unknownhttps://www.blogger.com/profile/03379403416236766572noreply@blogger.comtag:blogger.com,1999:blog-6393051114813114443.post-37836385188651720892007-04-26T01:53:00.000-05:002007-04-26T01:53:00.000-05:00Hi Lee,One post you might want to check out is my ...Hi Lee,<BR/><BR/>One post you might want to check out is my one on LINQ Query Syntax: http://weblogs.asp.net/scottgu/archive/2007/04/21/new-orcas-language-feature-query-syntax.aspx<BR/><BR/>It shows a good use for object initializers (which you didn't like above). It provides a really elegant way to "shape" the results of a LINQ query (and allow ORM data mappers to efficiently grab only the data from a database that is needed as a result).<BR/><BR/>Hope this helps,<BR/><BR/>ScottAnonymousnoreply@blogger.com