Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #18413

Re: startup code

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 <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: startup code
Date Wed, 29 Aug 2012 22:06:51 +0200
Lines 44
Message-ID <aa7b30Fa7aU1@mid.individual.net> (permalink)
References <9b4cce4e-99b1-414f-a033-1acf9200e90a@googlegroups.com> <2r4q38p3790lc86fpttn4arc58m5m1tjen@4ax.com> <3926176c-0940-4080-95a1-fb67bbbec50e@googlegroups.com> <aa4sm3FtuvU1@mid.individual.net> <c9e3596e-4091-4661-943a-a62f7e1ac4e0@googlegroups.com> <DdmdnV3jtJyVqKPNnZ2dnUVZ_jCdnZ2d@earthlink.com> <2667fee7-d27c-4d64-8fcc-501c188a2d33@googlegroups.com> <wN6dnbtMWafH-6PNnZ2dnUVZ_rOdnZ2d@earthlink.com> <k1lr9i$t23$1@dont-email.me>
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 <k1lr9i$t23$1@dont-email.me>
Xref csiph.com comp.lang.java.programmer:18413

Show key headers only | View raw


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/

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

startup code bob smith <bob@coolfone.comze.com> - 2012-08-28 11:48 -0700
  Re: startup code Roedy Green <see_website@mindprod.com.invalid> - 2012-08-28 11:53 -0700
    Re: startup code Lew <lewbloch@gmail.com> - 2012-08-28 14:00 -0700
      Re: startup code Robert Klemme <shortcutter@googlemail.com> - 2012-08-28 23:48 +0200
        Re: startup code Lew <lewbloch@gmail.com> - 2012-08-28 15:25 -0700
        Re: startup code Patricia Shanahan <pats@acm.org> - 2012-08-29 08:27 -0700
          Re: startup code bob smith <bob@coolfone.comze.com> - 2012-08-29 11:18 -0700
            Re: startup code Patricia Shanahan <pats@acm.org> - 2012-08-29 11:58 -0700
              Re: startup code Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-29 15:41 -0400
                Re: startup code Lew <lewbloch@gmail.com> - 2012-08-29 13:04 -0700
                Re: startup code Robert Klemme <shortcutter@googlemail.com> - 2012-08-29 22:06 +0200
                Re: startup code Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-29 17:14 -0400
      Re: startup code Roedy Green <see_website@mindprod.com.invalid> - 2012-08-29 00:21 -0700
        Re: startup code Patricia Shanahan <pats@acm.org> - 2012-08-29 02:42 -0700
          Re: startup code Patricia Shanahan <pats@acm.org> - 2012-08-29 02:54 -0700
    Re: startup code Arne Vajhøj <arne@vajhoej.dk> - 2012-08-28 19:20 -0400
  Re: startup code Jeff Higgins <jeff@invalid.invalid> - 2012-08-28 15:22 -0400
  Re: startup code Arne Vajhøj <arne@vajhoej.dk> - 2012-08-28 19:19 -0400

csiph-web