4/24/08 02:32 pm - Automatic properties in C# 3.0Ran across an article on new features in C# 3.0 today, and one of the features listed is Automatic Properties. The general gist is that it's too much trouble for some people to implement a field properly, so the compiler supports a lazy way to do it. This:
Can be written like this:So that's good, right? I'm not so sure. How is this any different from just exposing the private string in the first place? Like this:Of course all of this is moot if you need to do anything more advanced in the property than just returning or setting the value. For example, logging or range-checking or limiting the visibility of the setter more than the getter. Something like this:So, is it a big deal? Probably not. But it may make draft code faster to write, therefore it makes bad code easier to write because you get into bad habits. |
