<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-652174954000901332.post8614976567185847182..comments</id><updated>2008-07-20T06:29:12.540+01:00</updated><title type='text'>Comments on Øyvind Valland's Babel Lutefisk .net: Automatic properties; a great idea?</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.babel-lutefisk.net/feeds/8614976567185847182/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/652174954000901332/8614976567185847182/comments/default'/><link rel='alternate' type='text/html' href='http://www.babel-lutefisk.net/2008/07/automatic-properties-great-idea.html'/><author><name>Øyvind Valland</name><uri>http://www.blogger.com/profile/17595718624373482981</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-652174954000901332.post-1555196783379189721</id><published>2008-07-20T06:29:12.540+01:00</published><updated>2008-07-20T06:29:12.540+01:00</updated><title type='text'>Hello Jonas,Thanks for commenting! I concede that ...</title><content type='html'>Hello Jonas,&lt;BR/&gt;&lt;BR/&gt;Thanks for commenting! &lt;BR/&gt;&lt;BR/&gt;I concede that automatic properties have their place when it comes to dumb DTOs. In a previous life I had two libraries of DTOs (one for services, one for the DAL) that had to be kept in sync with each other. E.g. there was an Address DTO in one library (exposed as a DataContract) and an Address DTO in another library used with an Object-Relational Mapper (iBatis). Both classes would implement IAddress which defined all the properties on the interface. Without automatic properties maintaining and building these classes were a &lt;I&gt;real&lt;/I&gt; pain. &lt;BR/&gt;&lt;BR/&gt;As for the alternative to automatic properties (which you've appropriately wrapped in double quotes), I think it isn't an alternative unless you have a very good reason to expose a field directly - which isn't often.&lt;BR/&gt;&lt;BR/&gt;A lot of developers like to use properties for more than simple member variable access. Not that it's an example of good practice, perhaps, but having the ability to add some validation on a setter can be useful and it's a shame that this isn't supported with automatic properties. I like your idea of using events for this, and I can only hope that MS gives us a dual solution where you can use events &lt;I&gt;or&lt;/I&gt; create an automatic property where you can inject some code and work on the "value" parameter.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/652174954000901332/8614976567185847182/comments/default/1555196783379189721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/652174954000901332/8614976567185847182/comments/default/1555196783379189721'/><link rel='alternate' type='text/html' href='http://www.babel-lutefisk.net/2008/07/automatic-properties-great-idea.html?showComment=1216531752540#c1555196783379189721' title=''/><author><name>Øyvind Valland</name><uri>http://www.blogger.com/profile/17595718624373482981</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='18377601055500046677'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.babel-lutefisk.net/2008/07/automatic-properties-great-idea.html' ref='tag:blogger.com,1999:blog-652174954000901332.post-8614976567185847182' source='http://www.blogger.com/feeds/652174954000901332/posts/default/8614976567185847182' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-652174954000901332.post-4158795766320598472</id><published>2008-07-20T05:36:59.589+01:00</published><updated>2008-07-20T05:36:59.589+01:00</updated><title type='text'>Hi Øyvind!Again, another fine blog post :)Here are...</title><content type='html'>Hi Øyvind!&lt;BR/&gt;&lt;BR/&gt;Again, another fine blog post :)&lt;BR/&gt;&lt;BR/&gt;Here are some comments on why automatic properties matter.&lt;BR/&gt;&lt;BR/&gt;1) You can't databind against public fields. Alot of times you have really dumb data transfer objects, for instance the one automaticly generated by the web service proxy tools. This tool now generates classes with automatic properties so that you can bind against them.&lt;BR/&gt;&lt;BR/&gt;2) The "alternative" to a automatic property (a property with no backing set or get logic) is a public field. You might expose a public field, and lather when needed wrap it in a property. The problem with this is that changing from a field to a property changes the public interface of your class, so anything that is compiled against that class has to be rebuilt.&lt;BR/&gt;&lt;BR/&gt;If you're using an auotmatic property with no set or get logic, you can change this class later on, recompile, and not have changed the public interface of your class.&lt;BR/&gt;&lt;BR/&gt;3) It's just handy.. It saves time and keeps your code compact. There is no underlaying changes in the CLR, and if you dissasemble your code you will find a set_Name and a get_Name method, and a _name backing property.&lt;BR/&gt;&lt;BR/&gt;Personally I allways use automatic properties unless I know I'm going to change it, if so I use one of the properties code snippes to have a property with a get and set set up for my real quickly. Would also be cool if you could add some aspect oriented programming behaviour to automatic properties. Like saying this property should trigger the INotifyPropertyChanged.PropertyChanged event... :)&lt;BR/&gt;&lt;BR/&gt;Cheers,&lt;BR/&gt;Jonas Follesø</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/652174954000901332/8614976567185847182/comments/default/4158795766320598472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/652174954000901332/8614976567185847182/comments/default/4158795766320598472'/><link rel='alternate' type='text/html' href='http://www.babel-lutefisk.net/2008/07/automatic-properties-great-idea.html?showComment=1216528619589#c4158795766320598472' title=''/><author><name>Jonas Follesø</name><uri>http://www.blogger.com/profile/03186489878623898246</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.babel-lutefisk.net/2008/07/automatic-properties-great-idea.html' ref='tag:blogger.com,1999:blog-652174954000901332.post-8614976567185847182' source='http://www.blogger.com/feeds/652174954000901332/posts/default/8614976567185847182' type='text/html'/></entry></feed>