Sagewire Logo

additional visibility restriction for variables?

6 Message(s) by 5 Author(s) originally posted in java developer


From: Mike Kamermans Date:   Monday, February 26, 2007
A good day to all,

I was looking at the visibility levels for variable s 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'd 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'd 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 shouldn't be able to
directly access variables from a sibling object. From a design point of
view it shouldn't 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,'d do.

Thoughts anyone?

Sincerely,

Mike Kamermans
(Programming for the University of Amsterdam)


From: Lothar Kimmeringer Date:   Sunday, March 04, 2007
wrote in message :

I was looking at the visibility levels for variables in JAVA, and
realised that the current approach to variable visibility is incomplete:



[...]

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



BTW: You missed one level: package visible

I ran across this when I was making copy constructors and realised that
if I'm really programming object oriented I shouldn't be able to
directly access variables from a sibling object.



Sometimes I was thinking the same but I never was thinking
of an example were that really mattered. So at the end I
come to the conclusion that this type of visibility is
purely academical.

On the other hand I sometimes wish to have a way to declare
some class friendly to another...

BTW2: Since when exists comp.lang.JAVA.developer? On my
newsserver it does not.Regards, Lothar
--
Lothar Kimmeringer E-Mail: spamfang@xxxxxxxxxxx
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
questions!


From: Wojtek Date:   Sunday, March 04, 2007
wrote in message :
BTW: You missed one level: package visible



For which I wish there was a keyword....

--
Test Sig


From: Lew Date:   Monday, March 05, 2007
wrote in message:
wrote in message :
BTW: You missed one level: package visible
For which I wish there was a keyword....



There is:


From: Tom Hawtin Date:   Monday, March 05, 2007
wrote in message:
wrote in message:
wrote in message :
BTW: You missed one level: package visible

For which I wish there was a keyword....
There is:



Usually written /* pp */.

th


From: Lew Date:   Wednesday, March 07, 2007
wrote in message :
BTW: You missed one level: package visible

wrote in message:
For which I wish there was [sic] a keyword....

wrote in message:
There is:

wrote in message:
Usually written /* pp */.



Now *that* is a Best Practice.

-- Lew



Next Message: Web Start anyone?


Blogs related to additional visibility restriction for variables?

Enterprise Java Beans
However, the code here can be simplified by using an external Java class (a JavaBean) that retrieves and caches the home interface in a class variable instead. This increases the performance and enables code reuse, simplifying the ...

java pour ton citeweb
1 : 0; var dx, xp, yp; // coordinate and position variables var am, stx, sty; // amplitude and step variables var i, doc_width = 800, doc_height = 600; if (ns4up) { doc_width = self.innerWidth; doc_height = self. ...

C++ Faq
extern: a static variable whose definition and placement is determined when all object and library modules are combined (linked) to form the executable code file. It can be visible outside the file where it is defined. ...

RE: Jira Transition Search Plugin (created)
Improvement, SCRP-47, Add confluenceDomain pre-defined variable to java scripting macros, Bob Swift, Closed. New Feature, SCRP-46, Word macro - include contents from a Word document on a Confluence page, Bob Swift, Closed ...

Re: additional visibility restriction for variables?
Tom Hawtin wrote: > Lew wrote: >> Wojtek wrote: >>> Lothar Kimmeringer wrote : >>>> BTW: You missed one level: package visible >>> >>> For which I wish there was a keyword.... >> >> There is: > > Usually written /* pp */. ...

Re: additional visibility restriction for variables?
Lothar Kimmeringer wrote : >>>> BTW: You missed one level: package visible Wojtek wrote: >>> For which I wish there was [sic] a keyword.... Lew wrote: >> There is: Tom Hawtin wrote: > Usually written /* pp */. ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional