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


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

Re: trigger static init

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: trigger static init
Date Mon, 09 Apr 2012 09:19:11 -0700
Organization A noiseless patient Spider
Lines 14
Message-ID <jlv260$egk$1@dont-email.me> (permalink)
References <5605o7di8le7conanmf0g70p1ltipeqct4@4ax.com> <m2zkalqs1m.fsf@ipa.eternal-september.org> <jpn5o7t4jboj42onjom1adb45s6kaejed8@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Mon, 9 Apr 2012 16:19:12 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="QNqT5u6Ryx/DB+LpnoCWdQ"; logging-data="14868"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19RZ/2y4FfWB3O806LbhzPSIN5GH3bU09g="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1
In-Reply-To <jpn5o7t4jboj42onjom1adb45s6kaejed8@4ax.com>
Cancel-Lock sha1:xsqhK9ELABre01OIeMtQLXAgWUQ=
Xref csiph.com comp.lang.java.programmer:13459

Show key headers only | View raw


On 4/9/2012 6:09 AM, Roedy Green wrote:

> I decided to handle it by putting in dummy public static void fireup()
> methods that as a side effect load the class and run static init. If I
> fail to call them, class loading is just procrastinated until first
> use.


This sort of idea sounds to me like the worst sort of hackish design 
possible.  Don't use statics for this use case.  Use Factories, or 
Strategies, or even just a Properties object if you only need to load a 
few constants at runtime.

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


Thread

trigger static init Roedy Green <see_website@mindprod.com.invalid> - 2012-04-08 23:28 -0700
  Re: trigger static init Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2012-04-09 10:32 +0300
    Re: trigger static init Roedy Green <see_website@mindprod.com.invalid> - 2012-04-09 06:09 -0700
      Re: trigger static init markspace <-@.> - 2012-04-09 09:19 -0700
      Re: trigger static init Lew <lewbloch@gmail.com> - 2012-04-09 10:33 -0700
    Re: trigger static init Lew <lewbloch@gmail.com> - 2012-04-09 10:36 -0700
      Re: trigger static init Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-04-11 12:52 +0000
        Re: trigger static init Patricia Shanahan <pats@acm.org> - 2012-04-11 07:04 -0700
          Re: trigger static init Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-04-11 15:30 +0000
            Re: trigger static init Patricia Shanahan <pats@acm.org> - 2012-04-11 09:32 -0700
              Re: trigger static init Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-04-22 16:09 +0000
          Re: trigger static init Steven Simpson <ss@domain.invalid> - 2012-04-12 07:38 +0100
            Re: trigger static init Patricia Shanahan <pats@acm.org> - 2012-04-12 00:36 -0700
        Re: trigger static init Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-04-11 09:39 -0500
          Re: trigger static init Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-04-11 14:56 +0000
          Re: trigger static init Lew <noone@lewscanon.com> - 2012-04-11 08:08 -0700
  Re: trigger static init glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-04-09 09:18 +0000
    Re: trigger static init Roedy Green <see_website@mindprod.com.invalid> - 2012-04-09 04:57 -0700
    Re: trigger static init Lew <lewbloch@gmail.com> - 2012-04-09 10:31 -0700
  Re: trigger static init Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-04-10 12:22 -0700

csiph-web