I’ve long been fascinated by the impact that a culture’s language has on its thought processes and social interactions. Is the ease by which adjectives become nouns in Spanish a major factor in their culture of commonly calling people “fat one” (gorda), “old one” (vieja), and so forth?
In a related area, I’m interested in the changes that better tools have brought to the code that I write. For example, despite the advantages of Java 5’s enhanced For loop construct, I’ve only used it a couple of times because IntelliJ IDEA makes it so easy to write loops by typing “itli[tab]” and so forth.
And because of tools, today I finally stopped using wildcard imports. When I first starting writing Java code, I would frequently import “java.util.*” and so forth. In recent years, the IDE will automatically write the import for me, but it would often switch to wildcard imports once a certain number of classes from a package were used, or when certain packages were used (java.swing and java.awt, for example).
I decided that it just doesn’t make any sense to do wildcard imports, largely because file sizes are completely irrelevant to me and its worth sparing myself from the occasional conflict (java.awt.List, anyone?) to splurge on the extra bytes writing out import lines.
3 thoughts on “No More Wildcard Imports”
I prefer sticking with the wildcards. First, the conflicts are immediately flagged by the IDE, since the APIs are different (re java.util.List vs java.awt.List), and then i don’t like code folding, so i don’t like scrolling through pages of import statements to start reading the class. I always use 3->* in Eclipse preferences.
Why do code folding? I love having the imports folded. I find them utterly irrelevant. Whenever I write a new unqualified class name, IDEA asks me which instance I want in the event of a collision, and I never worry about it again.
The big win is the chances of collision dramatically decreases, and I just don’t see a long list of imports as offsetting that in any meaningful way.
You probably know this, but “iter” will give you the for loop. The new loops are much more readable imo.