|
![](/i/fill.gif) |
Warp wrote:
> The question here is: Are compiler-enforced private member variables a
> good thing in programming or not?
>
> Your argument why they are not: In C++ you can accidentally access them
> regardless of the compiler checks.
Actually, let me ask this. Since you seem to be saying that reflection means
that an OO system is a "kludge" because it breaks modularity, can you tell
me what language *you* think isn't a kludge in this respect? Since the
discussion mentioned "private:" and you defended the practice, I may have
wrongly assumed that indicated that you thought C++ wasn't a kludge OOPL in
this respect.
I don't know of any language that actually enforces modularity to the extent
where it's impossible to write code that depends on private variables of
another class, especially one to which you have the source. Every
language[1] where the trivial ways of doing this (e.g., reading the source
and using private names from outside the class) are enforced also has the
ability to bypass it without too much trouble (either by using reflection or
pointer arithmetic).
I don't know of any languages that make it trivially easy to *accidentally*
confuse private and public member variables, except *perhaps* PHP and Perl,
both of which I'll happily admit are kludges. :-) They might not make it
trivial, I don't remember, but if they do, I'm not surprised.
[1] except perhaps Ada - I'd have to go look closer to see if unchecked
conversions can do that sort of thing on tagged records.
--
Darren New, San Diego CA, USA (PST)
My fortune cookie said, "You will soon be
unable to read this, even at arm's length."
Post a reply to this message
|
![](/i/fill.gif) |