Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8305
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: borrowing Constants |
| References | <cf9q77h3gnhunlqpckpsobog4oqvlhiga7@4ax.com> <4e7d27e8$0$290$14726298@news.sunsite.dk> <86afq.26627$CY4.6386@newsfe04.iad> <02dq77p0i00lsfdsl78bfnencd2ab4a5gs@4ax.com> |
| Message-ID | <OmKfq.28055$GV2.4668@newsfe20.iad> (permalink) |
| Date | 2011-09-25 11:25 -0700 |
On 9/23/11 6:39 PM, Roedy Green wrote:
> On Fri, 23 Sep 2011 22:10:28 -0300, Arved Sandstrom
> <asandstrom3minus1@eastlink.ca> wrote, quoted or indirectly quoted
> someone who said :
>
>> Which logical place is not in the code at all. Granted, I don't know
>> that Roedy's example is doing anything more than using "VERSION" as a
>> generic variable name (I hope).
>
> I chose it as an easy-to-understand example. In my example, VERSION
> is something you might display in a an About box.
>
> The question is really about accidentally dragging in some giant class
> when you had no intention of using its code.
If you are using a field from it, you *are* using its code.
Imagine the following scenario:
public class MyConstants {
public static final String VERSION;
public static final int ZERO;
static {
ZERO = 0;
VERSION = SomeOtherClass.calculateVersionNumber();
}
}
public class UsesOtherClass {
public static final VERSION = MyConstants.VERSION;
}
When UsesOtherClass is initialized, it requires MyConstants *and*
SomeOtherClass to be initialized.
In general, if you use some code, you are transiently using its
dependencies as well.
Although, I thought I read somewhere that constants can sometimes be
inlined (which can lead to other surprising behaviors if you recompile
only some of your classes on make).
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
borrowing Constants Roedy Green <see_website@mindprod.com.invalid> - 2011-09-23 17:40 -0700
Re: borrowing Constants Arne Vajhøj <arne@vajhoej.dk> - 2011-09-23 20:44 -0400
Re: borrowing Constants Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-23 22:10 -0300
Re: borrowing Constants Roedy Green <see_website@mindprod.com.invalid> - 2011-09-23 18:39 -0700
Re: borrowing Constants Arne Vajhøj <arne@vajhoej.dk> - 2011-09-23 22:17 -0400
Re: borrowing Constants Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-09-25 11:25 -0700
Re: borrowing Constants Lew <lewbloch@gmail.com> - 2011-09-25 11:36 -0700
Re: borrowing Constants Arne Vajhøj <arne@vajhoej.dk> - 2011-09-23 22:30 -0400
Re: borrowing Constants Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-23 21:15 -0400
Re: borrowing Constants Roedy Green <see_website@mindprod.com.invalid> - 2011-09-23 18:43 -0700
Re: borrowing Constants markspace <-@.> - 2011-09-23 18:44 -0700
Re: borrowing Constants Lew <lewbloch@gmail.com> - 2011-09-23 19:19 -0700
Re: borrowing Constants Arne Vajhøj <arne@vajhoej.dk> - 2011-09-23 22:32 -0400
Re: borrowing Constants Lew <lewbloch@gmail.com> - 2011-09-23 19:11 -0700
Re: borrowing Constants Lew <lewbloch@gmail.com> - 2011-09-23 19:26 -0700
Re: borrowing Constants v_borchert@despammed.com (Volker Borchert) - 2011-09-24 09:44 +0000
Re: borrowing Constants Roedy Green <see_website@mindprod.com.invalid> - 2011-09-24 15:38 -0700
Re: borrowing Constants Roedy Green <see_website@mindprod.com.invalid> - 2011-09-24 17:09 -0700
Re: borrowing Constants Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-24 20:14 -0400
Re: borrowing Constants markspace <-@.> - 2011-09-24 18:18 -0700
Re: borrowing Constants Arne Vajhøj <arne@vajhoej.dk> - 2011-09-25 22:36 -0400
Re: borrowing Constants Arne Vajhøj <arne@vajhoej.dk> - 2011-09-25 22:35 -0400
Re: borrowing Constants Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-09-26 01:22 +0200
csiph-web