3 ms·
I'm not sure that the examples you cite make the point you want to make. Objective C 2.0 just introduced properties. One of the main reasons for this is to av
by jimbokun 18y ago
I'm not sure that the examples you cite make the point you want to make.
Objective C 2.0 just introduced properties. One of the main reasons for this is to avoid manually writing accessors.
I'm pretty sure that in Rails, you just give an annotation (I probably got the terminology wrong here) indicating what attributes you want to make accessible. Again, no manually written accessors.
I suppose this is different from the argument made by the article, but it is still an argument against WRITING accessor methods. Whatever benefits there are for having some kind of accessors mechanism, certainly there is no good reason for having to explicitly write methods to implement them. I never saw the point in writing "private int theNumber" immediately followed by "public int getTheNumber() { return theNumber; } public void setTheNumber(int n) { theNumber = n; }"
- allertonm 18y agoWhile the original article talked about accessors, the argument was really against publicly accessible properties on objects - even readonly properties. As demallien correctly argues, this approach breaks MVC. It's not stated outright, but the original author obviously has a Java or C++ background. The Java & C++ syntaxes for accessing a getter are different from those for accessing a public member, and as a result Java/C++ programmers almost always write accessors for all properties because it will be hard to change later.