why not import everything?

A

Arne Vajhøj

Peter said:
But, now I'm puzzled as to how that's supposed to address the issue of
writing the import in the first place, which is what I was talking
about. I didn't really understand what was being suggested here, until
just now.

My concern was in the process of writing the code in the first place.
What I'm looking for is a command that, having typed the name of a type,
will immediately add an import for that type (displaying a context menu
when the type name is present in multiple packages). As I mentioned,
"shift-command-M" (bound to the "Add Import" menu command) does that,
but only sometimes. :(

I realize I can always come back after the fact and change the imports
(even without the key binding, there's the menu command which as a
one-time-event is practically as easy to use), but it seems to me that
if a wildcard import is sufficient at some point in the development
process, it's sufficient at other points.

If you prefer so then nobody can see if you write the code as:
- write wildcard imports of all the relevant packages
- write all methods
- convert the wildcard imports to single class imports
- check into source control

Arne
 
R

RedGrittyBrick

Ctrl+Shift+O (or it's Mac equivalent Shift+Command+O) does exactly what
you want.

I can't understand why you haven't tried this. It's as if you have a
blind spot.

If you prefer so then nobody can see if you write the code as:
- write wildcard imports of all the relevant packages
- write all methods
- convert the wildcard imports to single class imports
- check into source control

For what it's worth I prefer

- Ignore imports, don't write any.
- Never write imports.
- Did I mention not to write imports?
- Yes that means any kind of imports!
- Peter, re-read the above until it comes into focus.

- Write code until a squiggly underline appears under a Class-name
- Press Ctrl+Shift+O
- Peter, that's Shift+Command+O on Macs
- No, really it is.
- Honestly, I'm not pulling your leg.
- Continue writing code

- Do all the other things.

:)
 
A

Arne Vajhøj

Joshua said:
Lew said:
I find this aversion to detail, such as hating one-type imports and
using import-on-demand, or avoiding repetition of type parameters in
the declaration and the 'new' expression, symptomatic of the "I don't
want to write any extra keystrokes, no matter how much that ends up
distressing the maintenance programmer" laziness that abounds.

The only complaint I have about generics parameter in new is that it's a
bit painful if you're using 80-character widths [1]. Then I remember
that I'm writing a generics Pair utility class and add in
Pair.makePair() static function and forget all about those extra
characters. :)

[1] Yes, I'm still using 80-width rules. I actually develop Java with
<favorite text editor here> in tiled 80x24 xterms.

You do not need to make excuses for the 80.

http://java.sun.com/docs/codeconv/html/CodeConventions.doc3.html#313

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,591
Members
45,103
Latest member
VinaykumarnNevatia
Top