tag:blogger.com,1999:blog-6184851556979812172.post1304652691394598643..comments2023-10-25T18:27:44.770+10:00Comments on Math Geek Coder: Quick Tip - Read Only Automatic PropertiesLuke Marshallhttp://www.blogger.com/profile/11665669405673984228noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-6184851556979812172.post-28138551901627983142007-11-28T22:28:00.000+10:002007-11-28T22:28:00.000+10:00One drawback - no initialisers on declarations. e....One drawback - no initialisers on declarations. e.g.:<BR/><BR/>bool IsHappy { get; set; } = true;<BR/><BR/>...doesn't have a chance of compiling :)<BR/><BR/>If you always use constructor chaining I guess that is nothing much to deal with. I do like being able to initialise fields in place though... :/Nickhttps://www.blogger.com/profile/02020072230899910249noreply@blogger.comtag:blogger.com,1999:blog-6184851556979812172.post-64800405954846450902007-11-28T21:57:00.000+10:002007-11-28T21:57:00.000+10:00Indeed! Even more since WPF data binding only wor...Indeed! Even more since WPF data binding only works with properties - manual fields seem quite irrelevant.<BR/><BR/>Then there's the compile time (and reflection) abstraction arguments. <BR/><BR/>i.e. Field and Property access look the same, but converting a field to a property down the track involves a recompile of all associated assemblies.<BR/><BR/>Thus it's better to adopt a property only approach in general.Luke Marshallhttps://www.blogger.com/profile/11665669405673984228noreply@blogger.comtag:blogger.com,1999:blog-6184851556979812172.post-29095996721036789772007-11-28T20:52:00.000+10:002007-11-28T20:52:00.000+10:00I've started to wonder whether this feature makes ...I've started to wonder whether this feature makes regular fields obsolete. It has always been good practice to encapsulate even private fields, however refactorings like 'encapsulate field' make the advantages a matter of syntactic consistency.<BR/><BR/>At least by adopting a properties-only approach, the argument over whether fields should be named with or without a leading underscore will finally be irrelevant!Nickhttps://www.blogger.com/profile/02020072230899910249noreply@blogger.com