[445] in java-interest

home help back first fref pref prev next nref lref last post

Adding "public readonly" class variables to java

daemon@ATHENA.MIT.EDU (jeff (j.d.) sparkes)
Thu Jun 22 14:11:36 1995

Date:  Thu, 22 Jun 1995 13:33:00 -0400 
From: "jeff (j.d.) sparkes" <jsparkes@bnr.ca>
To: java-interest@java.sun.com

I've been browsing through the java classes.  It seems that common
idiom is to have instance variables that are publically accessible.
This is a bit more efficient than an access function, but allows the
variable to be changed from outside the class.  This is good if you
want to allow that, but there are possible data security problems.

I propose adding a feature that (at least) Sather has.  You can
declare a variable as "readonly" which means its value can't be
changed outside of the class (or any subclasses.)  This is efficient
since you don't need to call a function to get the value, and safe
since variables won't unexpectedly change. It also makes the class
writers intended use of the variable clearer.  It might also add some
optimization opportunities.
--
Jeff Sparkes
jsparkes@bnr.ca    Bell-Northern Research, Ottawa, Ontario, Canada
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post