Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!zen.net.uk!dedekind.zen.co.uk!aioe.org!.POSTED!not-for-mail From: Roedy Green Newsgroups: comp.lang.java.programmer Subject: Re: borrowing Constants Date: Sat, 24 Sep 2011 17:09:24 -0700 Organization: Canadian Mind Products Lines: 39 Message-ID: References: Reply-To: Roedy Green NNTP-Posting-Host: RCd/Ul4tyxGUBII8WGwa5g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Forte Agent 6.00/32.1186 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8272 On Fri, 23 Sep 2011 17:40:20 -0700, Roedy Green wrote, quoted or indirectly quoted someone who said : >class A >{ > static String VERSION = "1.0b"; >} > >and >class B >{ >static String VERSION = A.VERSION; >} restating, if the expression for A.VERSION cannot be evaluated an compile time, even final won't rescue you from having to include both A in your jar and indirectly loading A when you load B. So the rule of thumb use static final with values known at compile time to avoid needless class loading. But be aware, you must recompile B if the value of A.VERSION changes, or you will get the old value. Another rule of thumb may be, instead of cross linking classes with references to each others constants, refactor out the constants to a third class, and reference it or extend it. In a number of my projects I have a Config class where everything constant (possibly computed) needed to configure a program for a particular use are collected. -- Roedy Green Canadian Mind Products http://mindprod.com It should not be considered an error when the user starts something already started or stops something already stopped. This applies to browsers, services, editors... It is inexcusable to punish the user by requiring some elaborate sequence to atone, e.g. open the task editor, find and kill some processes.