Jim C., 

> A private method cannot be extended, so does that mean it is final also?

<AFAIK>
In java, yes.
</AFAIK>

Object-oriented theory includes the concept of a constant.
A constant is an entity (e.g. field, method, or object) whose
value is the same throughout its entire extent.  (extent is
time of existence).

Nearly all object-oriented languages implement constants by enforcing
an assign-exactly-once policy.  java uses the 'final' modifier to denote
the need for this enforcement.

In theory, a private method, seen by all instances of that class, could
be reassigned by other methods within the same instance, and thus need
not be final.

<AFAIK>
In java, there is no way to create or modify a private method at run-time
(i.e. within the extent of an object).  Even private methods received
from serialized objects had to be compiled from source code prior to
run-time.

java.lang.reflect.* allows read access, and some limited address access
but not creation nor modification.
</AFAIK>



<AFAIK>
Consequently, since a java private method must be assigned its value
at compile-time and cannot be modified at run-time, a private method
must have the same value throughout its extent, and therefore be final.
</AFAIK>



In other languages (e.g. perl), that permit run-time reassignment of
private methods, such self-modifying code is a security and
maintainability issue.



In object-oriented theory, constants represent a dependency (e.g.
standards compliance, physical measurements, ...) outside the scope
of the algorithm expressed.

The use of constants is a trade-off between limiting the techniques
available to the optimizer, and promising the optimizer that
synchronization code can be safely removed.  Attempts to seperate
these two uses (and subsequently optimize both) have historically
proven unsuccessful.



<IMHO>
When using constants to express dependencies outside the algorithm,
the final modifier should be applied at the lowest level (field
rather than method or class) possible, and the comments should
point to the outside dependency (e.g. standard being complied with,
source of physical measurement, ...).
</IMHO>

Hopefully helpful,
-- 
Dr. Robert J. Meier


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to