antonio@apache.org wrote:
>Author: antonio
>Date: Sun Jan 2 13:26:59 2005
>New Revision: 123903
>
>URL: http://svn.apache.org/viewcvs?view=rev&rev=123903
>Log:
>Set static variable as final
>
>
Why should all static variables be final? This is necessary for public
constants, but not for internal variables. Although this changes nothing
for variables initialized when declared (e.g. "private static Map map =
new HashMap()"), it IMO reduces readability when the initialization
involves several steps in a static block as below:
> /** Batik's original default handler */
>- protected static ParsedURLProtocolHandler defaultHandler;
>+ protected final static ParsedURLProtocolHandler defaultHandler = ParsedURL.getHandler(null);
// Keep the default handler, if any
>
> /**
> * Change the default handler used by Batik to resolve URLs to a handler
>@@ -56,9 +56,6 @@
> * @param logger the logger for logging.
> */
> static {
>- // Keep the default handler, if any
>- SourceProtocolHandler.defaultHandler = ParsedURL.getHandler(null);
>-
> // Set the default handler to our handler
> ParsedURL.registerHandler(new SourceProtocolHandler(null));
>
>
Sylvain
--
Sylvain Wallez Anyware Technologies
http://www.apache.org/~sylvain http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
|