On May 7, 2006, at 5:00 AM, dblack / wobblini.net wrote:

> Hi --
>
> On Sun, 7 May 2006, Logan Capaldo wrote:
>
>> I would suggest using the attr_* methods or writing your own  
>> accessors for any case where you might need to access an instance  
>> varible
>>
>> @something = exp
>>
>> is probably a bad sign anywhere but initialize and/or
>>
>> def something=(x)
>> ...
>> end
>>
>> likewise a = @something should almost always be a = self.something
>
> It all depends.  The attr_* family uses instance variables to do what
> it does, but there's no reason that should be viewed as the only or
> best or likeliest use of instance variables.  It's layered on top of
> a subsystem (instance variables) that have other uses too.
>
>
> David
>
I wans't suggesting only using ivars for accessors, but I believe  
strongly in the uniform access principle. Even if you using ivars for  
something completely internal that no one sees, you should still wrap  
the accesses to them in methods (private ones).


> -- 
> David A. Black (dblack / wobblini.net)
> * Ruby Power and Light, LLC (http://www.rubypowerandlight.com)
>   > Ruby and Rails consultancy and training
> * Author of "Ruby for Rails" from Manning Publications!
>   > Paper version coming in early May! http://rubyurl.com/DDZ
>