• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Coding Standards

 
Sri Addanki
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If i have something like this, is it ok?
import suncertify.db.*;
import java.util.*;
or do i need to mention the classes that i import too...
thanks,
sri
 
Matt Ghiold
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My rule of thumb is if your are only incorporating 1 or 2 classes from a package I do it explicitly, otherwise, I do the *.
But, as a general rule there is no performance penalty or excess overhead from using a *, so I
don't think it's a big deal to do a * as it won't affect your program at all.
 
Mag Hoehme
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
IMHO the most important think about coding standards is that they are sound and consistent.
The most popular style guide is Vermeulen's "The Elements of Java Style" (also available online).
Regarding the import statements, I've seen different argumentations on how to do it. I used Eclipse, which automatically creates import statements for each imported class (without *), and removes all unused imports.
However, there's a rationale for using imports with a "*" (in real life): First, it forces the programmer(s) to name their classes in an unambiguous way. Secondly, when the classes are to be refactored, you save all the retyping of the import statements.
Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic