Holub mentioned several times that automated tools that mindlessly create get/set methods based on instance data are satan incarnate, because they don't make the developer write objects the right way. If you manually go write all those get/set methods, you're doing just as bad a thing. He was arguing that writing your objects that way has really nasty effects, all of which are based on the ability for objects to access each other's state. If objA needs to perform an action on some of objB's state, have objA request that objB does it, don't have objB give objA the state and let it do it. Gratuitious get/set methods lets this latter type of architecture be very easy for developers to fall into. I know I've done it. But then I stopped automatically including get/set methods when I was making class diagrams, instead only adding them as needed, and the problem went away.
I really think he has a very valid point, just didn't communicate it well. --- Barney Boisvert, Senior Development Engineer AudienceCentral [EMAIL PROTECTED] voice : 360.756.8080 x12 fax : 360.647.5351 www.audiencecentral.com > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Behalf Of Brad Howerter > Sent: Friday, September 12, 2003 9:45 AM > To: '[EMAIL PROTECTED]' > Subject: RE: [CFCDev] Getters and Setters WAS: DB and OO question > > > You're right, Ray, noone is saying we should make getters and setters for > all instance data, and there would be no reason to write an article to > convince people not to do that. > > That wasn't the point of the article. The point was that getter/setter > functions are evil. Holub's saying it doesn't make sense to share atomic > data with the world. > > -----Original Message----- > From: Raymond Camden [mailto:[EMAIL PROTECTED] > Sent: Friday, September 12, 2003 10:42 AM > To: [EMAIL PROTECTED] > Subject: RE: [CFCDev] Getters and Setters WAS: DB and OO question > > > > > Yeah, you bet. Just don't make getters and setters for all > > your instance data, just for the hell of it. To put it > > another way, create the interface based on the needs of the > > object's clients, don't create it to the set of instance > > variables you have. That was really the point of the > > article, though he never bothered to make it clear. Good > > point, bad writing style, but that's just me. > > > > If that was the point of the article, I must be an idiot to have it > missed it then. ;) Seriously, I don't think I've heard anyone here say > you should blindly make get/set* for all your data. Maybe it was just > too obvious to me already that you only add get/set for data that makes > sense to share with the world. > > -rc --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/2003 ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
