
Signature
Daniel Dyer
http://www.uncommons.org
>> I am considering using static imports in my Java code and was
>> wondering whether there was a performance cost or resource issues
[quoted text clipped - 15 lines]
> but I would be extremely surprised if the the compiler did not generate
> exactly the same output whether you use static imports of not.
It has to. It's required to. It must. Imports, static or otherwise, are
strictly for the compiler.
Me, I prefer to keep the class name in the static references for the most
part. I don't know why so many people are so lazy about such things - I read
a lot of whining about "extra" typing. Try being the maintenance programmer
who has to debug the thing a year later and you will truly appreciate leaving
the class name in the expression.
Sometimes you have to think of others when you're coding.

Signature
Lew
Robert Klemme - 16 Dec 2007 13:00 GMT
>>> I am considering using static imports in my Java code and was
>>> wondering whether there was a performance cost or resource issues
[quoted text clipped - 26 lines]
>
> Sometimes you have to think of others when you're coding.
Although I tend to agree to the whining part ;-) in this particular case
with a modern IDE like Eclipse you'll find the originating class as
easily in both cases (static imports really cut off just one more item
from a qualified name). Not working with such an IDE would be a far
bigger mistake than using or not using static imports. My 0.02 EUR.
Kind regards
robert
Lew - 16 Dec 2007 19:40 GMT
> with a modern IDE like Eclipse you'll find the originating class as
> easily in both cases (static imports really cut off just one more item
> from a qualified name). Not working with such an IDE would be a far
> bigger mistake than using or not using static imports. My 0.02 EUR.
Good point, and it cuts both ways. With a good IDE like that it'll insert the
expression with the class name with no more than a couple of Ctrl-Space /
click combinations.
Static imports are often quite useful and when it makes a program clearer
they're absolutely the right thing to use. The original question was about
run-time impact, of which there's none. The source-code question is always
about what makes the code easier to develop and maintain correctly.

Signature
Lew
Robert Klemme - 16 Dec 2007 21:44 GMT
>> with a modern IDE like Eclipse you'll find the originating class as
>> easily in both cases (static imports really cut off just one more item
[quoted text clipped - 4 lines]
> insert the expression with the class name with no more than a couple of
> Ctrl-Space / click combinations.
Yepp, definitively.
> Static imports are often quite useful and when it makes a program
> clearer they're absolutely the right thing to use. The original
> question was about run-time impact, of which there's none. The
> source-code question is always about what makes the code easier to
> develop and maintain correctly.
Full ack!
robert