Re: C# 3.0 partial methods and automatic properties
Keith Hill <[email protected]> Wed, 22 Nov 2006 12:00:45 -0700
| Newsgroups | gmane.comp.windows.devel.dotnet.cx |
|---|---|
| Message-ID | <512BE27FB3EF0B42B619503F8ECB109B014B256F@wcosmb05.cos.agilent.com> |
> -----Original Message----- > From: Jon Skeet [mailto:[email protected]] > Sent: Saturday, November 11, 2006 12:23 AM > Subject: Re: C# 3.0 partial methods and automatic properties > > Creating a code snippet or a macro or whatever has a problem in terms of > readability though. Let's take another example of syntactic sugar: > "using". I'm sure that Eclipse can add a try/finally block round my Java > code easily, but I'm *much* happier reading C# code with the "using" > statement. > > Similarly, it's easier to read: > > public property string x; // Or whatever the syntax is > > than the "longhand" version, even if that longhand version *has* been > generated for you. > > Typing speed is rarely an issue for me, but quickly reading and > understanding code often is. I agree. The VS IDE doesn't help when I'm reading code nor does it help when I write code outside of the IDE (yes I sometimes use notepad). I think the automatic property feature complements the "event" keyword which essentially does the same thing - create a private field (delegate) and generates the Add/Remove methods for you. In both cases, if you need more functionality, then you don't use the feature i.e. write your own get/set or add/remove methods. The other issue I think that C# needs to stay on top of is remaining competitive with various dynamic languages. There is a *lot* less line noise in languages like Ruby and Python. Check out this MSDN article on IronPython: http://msdn.microsoft.com//msdnmag/issues/06/10/clrinsideout/default.aspx Dynamic languages like Python are popular for a reason - their syntax doesn't get in the way as much, requiring a lot less typing (keyboard typing). By the way I don't agree with the statement in the article that the line noise in C# is necessary. There are places where it isn't. Take for instance the new type inferencing/var feature in C# 3.0. I think this can help reduce line noise a fair amount e.g.: Dictionary<string,Dictionary<string, Foo>> bar = new Dictionary<string,Dictionary<string, Foo>>; versus var bar = new Dictionary<string,Dictionary<string, Foo>>; The automatic property syntax is just another step in the direction of eliminating unnecessary line noise. What I like about these features is that you get some of simplified syntax found in dynamic languages without giving up static type checking and the features that go along with it like Intellisense. BTW, it's interesting that the C++ team thought the simplified property syntax idea worthy enough to add to the managed extensions for C++. -- Keith =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com