Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #26282
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: static data for methods... |
| Date | Thu, 10 Oct 2013 14:44:15 +0200 |
| Organization | A noiseless patient Spider |
| Lines | 36 |
| Message-ID | <l367f1$iqm$1@dont-email.me> (permalink) |
| References | <slrnl5ape4.mol.avl@gamma.logic.tuwien.ac.at> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Thu, 10 Oct 2013 12:44:17 +0000 (UTC) |
| Injection-Info | mx05.eternal-september.org; posting-host="d13404d57b2028fe1900165c7807070a"; logging-data="19286"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/E72NIyjocZHGo//6yY887" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 |
| In-Reply-To | <slrnl5ape4.mol.avl@gamma.logic.tuwien.ac.at> |
| Cancel-Lock | sha1:YoBT3NisV0kDnp+GSB4Es92nT40= |
| Xref | csiph.com comp.lang.java.programmer:26282 |
Show key headers only | View raw
On 2013-10-09 16:18, Andreas Leitgeb allegedly wrote:
> I'm aware that in Java, methods cannot have static data within
> them. The usual "workaround" is to place static data for a
> method in static fields of the class. However, I need the
> static fields lexically separated for the methods.
>
> My first thought was to write a static class named after the
> method, then start the method like this:
>
> static class static_fuBar { static int foo; static int bar; ... }
> public static void fuBar(...) {
> import static static_fuBar.*;
> // now use foo and bar by their bare names ...
> }
>
> That of course doesn't work, either, because Java is very
> restrictive about where "import static" can be used. (I added
> it merely to illustrate what I'd like to arrive at.) Is there
> some other trick?
>
>
> PS: besides fuBar, I'll also have a couple further methods with
> each's own set of effectively-static canonically-named fields, so
> making foo&bar just static fields of the main class is not an option.
> also renaming each foo and bar to <methodname>_foo and <methodname>_bar
> isn't satisfying.
>
> PPS: If this path of thought is really a dead end, then I'll do
> the backtracking, myself, so no need asking for the broader picture.
>
Quick Q: is this you trying to be economical while doing a refactoring,
or you designing a FUBAR'd mess?
--
DF.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
static data for methods... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-10-09 14:18 +0000
Re: static data for methods... taqmcg@gmail.com - 2013-10-09 07:49 -0700
Re: static data for methods... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-10-09 15:42 +0000
Re: static data for methods... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-10-09 15:29 +0000
Re: static data for methods... Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-10-10 14:44 +0200
Re: static data for methods... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-10-10 13:13 +0000
Re: static data for methods... Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-10-10 15:44 +0200
Re: static data for methods... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-10-10 17:26 +0000
Re: static data for methods... Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2013-10-11 22:03 -0700
Re: static data for methods... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-10-18 15:31 +0000
csiph-web