[Tutor] Private and Public variables

Gonçalo Rodrigues op73418 at mail.telepac.pt
Fri Oct 10 10:25:50 EDT 2003


On Wed, 8 Oct 2003 21:02:34 +0100, you wrote:

>> they are still with me. I think one of the reason's why is because I
>> tend to favor (following the gang of 4) composition to inheritance.
>
>What does that have to do with data hiding (the correct term
>for private data)?

Good question :-)

I guess this is one of those situations where by conflating the issues
in your head things just get more complicated and muddled.

[text snipped]

>> So, what do you guys think?
>
>I think your design ideas are correct, the need for data hiding
>and the implied distrust of your fellow programmers is perhaps
>more questionable.

The implied distrust is not towards my fellow programmers, is more
towards me...

But I guess I do need to relax a little more...

>
>But if you design classes to expose a behavioural interface
>then the ability or lack of to directly access data will not
>be of any concern to your users.

Exactly, that's what I try to do.

I believe the "we're all consenting adults" philosophy is the Right
Philosophy. The name-mangling feature for attributes of the form
__my_attribute is also very good IMHO, since nothing is really hidden
and a client can always work around bugs and/or missing features. At
the same time it gives a clear signal to the client that if he mucks
with this attribute he does so at his own risk.

With my best regards,
G. Rodrigues



More information about the Tutor mailing list