 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Mike Kamermans Guest
|
Posted: Mon Feb 26, 2007 6:46 pm Post subject: additional visibility restriction for variables? |
|
|
A good day to all,
I was looking at the visibility levels for variables in JAVA, and
realised that the current approach to variable visibility is incomplete:
while an object oriented programming langauge, the visibility issue has
been defined from a class oriented perspective. While class definition is
an aspect of object definition, it's not the whole story, leading me to
conclude that a proper object-level visibility definition is missing.
How much animo would there be for a fourth visibility marker that marks a
variable as accessible by "this" object only, rather than objects that
share the same class as "this"? It would basically lead to the following
"hierarchy":
public - full visibility
protected - visible to any object being or extending "this" class type.
private - visible to any object being of "this" class type
restricted - visible only to the object in which it is defined
I ran across this when I was making copy constructors and realised that
if I'm really programming object oriented I should not be able to
directly access variables from a sibling object. From a design point of
view it should not be possible for any object to mess with the internals
of another object if these internals are to be truly considered
"private" in the linguistic sense of the word.
I picked the word "restricted" mostly because "owned" seemed an odd word
to use (especially given its meaning in the coder community), but any
word that in some way implicates object-level visibility, rather than
class-level visibility, would do.
Thoughts anyone?
Sincerely,
Mike Kamermans
(Programming for the University of Amsterdam) |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|