I didn't make the comment, but I'll take a crack at the answer, if you'll allow it.
Data Abstraction is arguably the most important, and I think most overlooked feature, of Object Oriented Programming. You want your classes to be self-contained experts on their field of interest. As experts, they should be capable of handling the task for their data, instead of exposing that data so others can handle the tasks for them.
That's the heart of OO Design, in my opinion, though you rarely see this pure form in "the wild". To me, that's what Design Patterns are all about, tactics to preserve this encapsulation in Real World I'm-Going-To-Need-To-Maintain-This Software.
Generally, programmers design classes to hold some related data and do a few things with it. Then they throw in a bunch of accessors so user code can see what happened/export/HTMLify or about a million other uses. We're always "pulling" data out, but The Right Way (My opinion!) to do objects is to "push" the details into the expert object instead. (Matz eluded to this in a recent post, though he was quasi-discussing the web.)
We know public instance data is BAD, right? How does putting a method over it make it all better? The weak answer is that it provides you with an option to change how that data is stored in the future. If that's the case, why give access to it at all? It creates tighter dependancies with all user code and we all know that's bad because it complicates maintenance. Go the distance and just don't give out the data to begin with. Instead, tell users, you just give me what I need and I'll handle it for you.
Don't read all the data and export it to some format, pass in some kind of "exporter form" object, the expert can fill out. Don't poll a Clock object for the current time, ask it to notify you when the time you desire has been reached. Don't have a Car manage it's location details through accessors, have the Map object pass in the Car's current location as an argument to a method that needs it.
"Ask for help, not information."
The above is the reminder I use to test if I'm designing correctly. There are exceptions, of course, but that's the central focus of OO Design to me.
Hope that helps and I hope I didn't put too many wrong words in Dave's or Matz's mouths.
James Edward Gray II
···
On Nov 11, 2004, at 2:26 PM, Hal Fulton wrote:
Dave Thomas wrote:
A class with a large number of attr_accessors is not really an encapsulated class
Now *that* is food for thought. It makes me have second thoughts
about some of my recent code.
Would you be interested in elaborating on this theme?