commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Ivankovits <>
Subject Re: [vfs] final usage
Date Mon, 21 Jun 2004 12:47:34 GMT
Rami Ojares wrote:

>Why does vfs use everywhere possible final modifier?
>Is this some kind of performance optimization or some
>design issue?
Here i find a (IMHO) good summary about the various "final"s

There is a performance aspect when using "final" often - the jvm can 
aggressive optimize (whatever that means), but IMHO this was not the 
(only) indention of the original authors.

As i see the OO design of VFS they used it as one component.

*) final parameters for methods ensures that - within the method - no 
one changes the reference, this is not relevant for the caller, but as a 
developer you can be sure the meaning of the parameter wont change.
(I hope i could express this with my english ;-)
*) final class members ensures also that no methods changes this value - 
again a great helper for the developer who would like to use the value, 
he do not have to understand the class in its very last detail. E.g. 
find a place where this value changes - it isnt changeable.
Also this is a great helper for yourself - as you can ensure no other 
developer (including yourself ;-)) can change this value by mistake and 
make the whole class stopping from work.
*) final classes ensures that no one can derive from them and e.g. pass 
a faked object to the system (security)

I also used final for those aspects before i come to VFS - i found it 
very usefull.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message