[izpack-devel] OT: Java Imports in IzPack

Hal Vaughan hal at thresholddigital.com
Sun Mar 12 18:42:38 CET 2006


On Saturday 11 March 2006 12:49, Elmar Grom wrote:
> Hi folks,
>
> yes this one of the widely recommended best practice rules, though I
> have yet to fathom the advantages. As Klaus mentions, occasionally an
> ambiguity arises if two (or more) imported packages contain a class
> with the same name. However this is not a problem, just a minor
> annoyance that is easily fixed by specific imports. The compiler will
> never make a pick on its own (which might be wrong) and thus cause a
> problem. It will always produce an error and stop compiling.
>
> Actually the only way to get the wrong class is be USING specific
> imports and making a mistake there. But even that is a very remote
> possibility, since most likely the API of the two classes will differ
> enough to cause problems.
>
> The best benefit that I can see is the fact that you naturally build
> an inventory of all the external classes that are used in your code
> (though I have yet to make use of this information). This is of
> course only true it you are very diligent in also deleting all
> imports for classes that you have removed while making changes.
> Otherwise it only represents a mess.

I can't see a reason that information would be used, either, but one 
thing I've noticed and like about Eclipse is that it is good about 
showing which imports and variables are never used.  That makes it 
easy, when you're done, to clean up the list of imports.

I did just find a glitch in this feature in Eclipse, though.  I have a 
main(String[] args) method that sets 3 variables from the arguments 
passed from the command line and uses them once, to construct the class 
before calling a method in it.  Eclipse keeps flagging those variables 
as unused when they are used.  Guess everything has a bug in it.

Hal



More information about the izpack-devel mailing list