Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: startup code Date: Wed, 29 Aug 2012 22:06:51 +0200 Lines: 44 Message-ID: References: <9b4cce4e-99b1-414f-a033-1acf9200e90a@googlegroups.com> <2r4q38p3790lc86fpttn4arc58m5m1tjen@4ax.com> <3926176c-0940-4080-95a1-fb67bbbec50e@googlegroups.com> <2667fee7-d27c-4d64-8fcc-501c188a2d33@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net wDym5KqlkidTFmj6c0f76Q0UJYTIOGP8pNuIC5fZG/S0uqjUoM/MVNt5gGe4kjyzM= Cancel-Lock: sha1:0Eo5vCyEgAu2/UsX0SEKZFJnVVY= User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:18413 On 29.08.2012 21:41, Eric Sosman wrote: > "What she said," with a stylistic suggestion: If the code to > create the bitmap grows to more than a very few lines, consider > putting them in a private static method of their own and calling > that method from the static initializer: > > class Thing { > ... > static { > createTheBitmap(); > } > > /** Called only during class initialization. */ > private static void createTheBitmap() { > // create the bitmap > } > ... > } > > Doesn't change the code's meaning in any significant way, but > may make it easier to debug/adapt/refactor later on. If you go through the effort why then call it from an initializer? Why not just via the field declaration that holds the bitmap? class Thing { private static final BitMap bm = loadTheBitmap(); private static BitMap loadTheBitmap() { ... return ...; } } Assuming that the state will be held in this class. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/