C# - Generics & Refactoring / Edit&Continue (EnC)
Whidbey GAC & 64 bit

Properties and Fields

Martin Fowler blogs about that he liked the notion of properties from the beginning (compared to Java's getX/setX).

However, he doesn't like that fields and properties are handled differently by reflection, so it is not possible to change a field to a property afterwards. Now he has to write "stupid accessor functions for accessible data values".

I think this is just an issue on how much work it is to write properties. Using Whidbey, this is a fast & simple task. For VS.NET 2003 Frans Bouma has written a Macro to create properties.

Christian

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

Dennis v/d Stelt

Hahahaha, I think it's Frans Bouma. Did you do the mistake on purpose? ;)

Christian

Thanks Dennis! No, I didn't do the mistake on purpose. Already corrected.

Scott

For VS.NET 2002/2003 I am a big fan of QuickCode.NET: http://www.dvxp.com/en/Downloads.aspx -Scott

vnrg

i don't think it's only a problem of generating an access code. the problem is that this code is relatively unnecesarry.

Christian

vnrg, I don't agree with you that this code is unnecessary. Do you prefer public fields or get/set methods instead of properties? I prefer properties.

vnrg

so what properties really are? aren't they just functions? what is the purpose of declaring public field in the class? isn't all this just an implementation detail? maybe i am going too far and trying to argue about fundamentals of .net core. maybe JITting could solve this for us. maybe IL could be more abstract. maybe not ;) and of course i'm using properties. but that was the point: why?

Christian

Of course, properties are just functions. However, the caller uses properties similar to fields - I prefer this in contrast to the setX(), getX() style with Java. I don't see your relation with public fields. What's your point with that regarding properties? Sometimes it is OK to use public fields, e.g in the automatically generated classes from the wsdl.exe utility.

Christian Nagel's OneNotes

AUTHOR: Christian Nagel's OneNotes
IP: 000.000.000.000
DATE: 12/17/2004 09:52:00 AM

Christian Nagel's OneNotes

AUTHOR: Christian Nagel's OneNotes
IP: 000.000.000.000
DATE: 12/17/2004 10:42:00 AM

CHERRYMAYER

According to my own monitoring, billions of persons all over the world receive the home loans from well known creditors. Thence, there's good chances to get a term loan in any country.

The comments to this entry are closed.