From: Alex Fenton Date: 2005-12-14T05:42:39+09:00 Subject: Re: Private attribute or accessor? Sam Kong wrote: > In my opinion, if there're accessors (getter and setter), using them in > the class is better than directly accessing the instance data. > However, most codes I've seen access the data directly. Another advantage of using accessor methods (self.foo = ) over variables (@foo =) is that it can help avoid typo bugs. Variables are initialised to nil, so if you write @the_variable in one place and later elsewhere read @thevariable, you don't get an immediate complaint. If you typo an accessor method, you get an immediate NoMethodError . I've moved to this style over time - also because it's easier (I find) to do things using method reflection - eg adding and notifying observers. a