commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Ivankovits <ima...@apache.org>
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
http://renaud.waldura.com/doc/java/final-keyword.shtml

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.

-- 
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message