From: Joe Cheng Date: 2003-08-17T07:37:12+09:00 Subject: Re: Newbie Q: Data encapsulation with Ruby > Ruby is good this way: objects can choose to expose their state > directly, *but then they can change to having more complex method-based > access.* [emphasis added] Once again, Dave Thomas hits the nail on the head. The reason attr_reader and attr_writer are OO-approved (at least, to the degree that Java getX and setX accessors are) is because you can override their behavior later. The same would not be true of making Java fields public, since there is no way you can "intercept" direct field access and no way to write methods that look like direct field access. (I think the same is true in C++?) I think the way Ruby's instance vars and attrs work is the safest, most convenient idiom I've seen for this sort of thing...