Via Reddit, I just read an article about how much better C# is than Java. As a language, this might be true, the platform is another thing. However, one of the things many people think is missing from Java is properties, presumably so you don’t have to write those getters and setters all the time.
First of all, I don’t know who actually writes that stuff – all modern IDEs can generate them automatically. Secondly, how do you actually know when to implement something as a property or as something which looks like a setter/getter? I haven’t done much C#, but I have seen quite a lot of classes containing both properties and getters and setters without any obvious reason. Isn’t this an indication that properties somewhat violate OO encapsulation? Why do I have to know if something is
a special property or not?
However, the main reason why I dislike properties is that I’m lazy. If I need to set a property on an object, but I don’t know which ones are available, I will type obj.set and hit the autocompletion key like Ctrl-space in Eclipse. This will then give me all writable properties. Likewise, I can do obj.get and hit the key and get all readable properties. I know, “real” properties are displayed as being readable and/or writable, but they’re then mixed with all the methods on the object too, and I’ve already seen way too many attempts at setting a read-only property, exactly because of this.



