On Sun, Apr 15, 2001 at 12:19:23PM -0700, Aaron Lehmann wrote:
> You're right on everything, except for:
> On Sun, Apr 15, 2001 at 05:16:31PM +0200, Joaqu?n Cuenca Abela wrote:
> > 3) Please, please, please:  NO public/protected variables.  Period.  Try
> > to avoid public virtual members, too.
> > This one need a bit of collaboration from everybody.  I will not go
> > through all the code and fix that.  It should be fixed in an incremental
> > way with the help of everybody.
> This is crazy. Why is using foo->get_bar() better than foo->bar other
> than adding complexity and obfuscating the code?
> Ok, maybe I'm a renegade C programmer who never learned.

Even as a renegade C programmer, what you probably meant was:

  foo->bar()

In OO, an object's data should always be private to that object.
IMHO, if foo had a bar prop then:

  foo->bar() returns the bar prop
  foo->bar(newval) set bar to the new val.

Advantages: code less clumbersome (there's a bar prop that's manipulated by it's 
methods) since you have "one" (since they're two actually) method in which you get/set 
the bar property.

Howver, if bar is just a public property in which you access by:
  foo->bar

than that is bad, since the mantainer of the foo class could change the way it worked, 
and then you might break the code on that account.

Using the provided methods, at least can provide a way to implement some backward 
compatibility (for instance, the foo->bar(value) does nothing, and foo->bar() returns 
"").

Hugs, rms

PGP signature

Reply via email to