From: Philipp Hofmann Date: 2008-02-14T03:09:45+09:00 Subject: Re: @var = change to accessor method? Why? On Wed, Feb 13, 2008 at 05:51:33PM +0900, Ryan Davis wrote: > >> ... > > I'm afraid you're confusing encapsulation with information hiding [0], i don't think so, but thank for pointing me to that article. without reading it, i would have thought: hm, presumably he is right, i'm confusing something. ;) > ... > > Providing accessor methods is the only sane way to make your code and > its subclasses more resilient to change. It allows you to change the > internals without affecting the subclasses that use that interface. > Classes that use ivars directly are more brittle and require more work > to maintain. that is in fact a good point. i wasn't aware of that. and might make me change my mind. could you or anyone else point out a problamtic case in few lines of code? just curious. >> ... > > [0] http://c2.com/cgi/wiki?EncapsulationIsNotInformationHiding > [1] As I've said before, if it is anywhere in ruby and evaled or parsed > in any way, I can get my hands on it and manipulate it. If that scares or > bothers you, you're using the wrong language. I totally agree. But it still makes a difference for what reasons e.g. 'send' is used. It's on thing to use it for some nifty metaprogramming but it's another to exploit it to access an otherwise (maybe for a good reason) unaccessible object. g phil