Re: C# 3.0 partial methods and automatic properties

Sebastien Lorion <[email protected]> Mon, 13 Nov 2006 01:52:12 +0800
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <[email protected]>
I think very careful consideration should be given to cost vs benefits when
adding new syntax to a language. In this particular case, the benefits are
very slim IMHO. When I create a new class, I add a new region "Properties",
put properties + related fields there and then forget about it. Other kind
of fields are put into a "Fields" region and that's it, end of the story. I
think the "problem" is a mere inconvenience which can quickly be solved with
a code snippet (default "prop" or custom).

On the other hand, having this kind of syntax introduces some ambiguities:

- how to name the related field ? Every one has different conventions, every
language has different restrictions, etc.
- for any particular cases (and there is really a *lot* of them), you still
need to use the "longhand" syntax
- what about different scopes on get/set ?
- etc.

Compare this with the "event" keyword for which none of the above applies.

What would be nice is if the IDE would popup an Intellisense dropdown after
it detects we just created a field and would offer a choice of snippets to
apply (eg. simple get/set property on one line/multiple line, with
PropertyChanged event notification, storage in dictionary/view state, etc.).

Sébastien

> -----Original Message-----
> From: Discussion relating to the specifics of the C# and Managed C++
> languages [mailto:[email protected]] On Behalf Of Jon Skeet
> Sent: Saturday, November 11, 2006 3:23 PM
> To: [email protected]
> Subject: Re: [DOTNET-CX] C# 3.0 partial methods and automatic
> properties
> 
> Sebastien Lorion wrote:
> > I think creating a code snippet would be more simple for this kind of
> > task...
> 
> 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.
> 
> Jon
> 
> ===================================
> This list is hosted by DevelopMentor®  http://www.develop.com
> 
> View archives and manage your subscription(s) at
> http://discuss.develop.com

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com