Style Guide Proposal: Prefer importing classes

12 views
Skip to first unread message

Sky Malice

unread,
May 18, 2026, 12:48:21 PM (4 days ago) May 18
to ja...@chromium.org
Hello ja...@chromium.org

I would like to formally update the styleguide/java/java.md to call out that importing classes before usage is better, eg

import org.chromium.foo.Bar;
...
Bar bar = new Bar("", false);

Rather than fully qualifying at the point of usage

org.chromium.foo.Bar bar = new org.chromium.foo.Bar("", false);

I think there is an implicit assumption shared by all of us humans working on Chrome that this is the better and natural way to write Java code. But recently AI has been fully qualifying classes. As a we build new AI tools, and reference our style guide, I want to ensure the guide explicitly calls this out to give us the best chance of fixing this systematic problem.

Thanks,
Sky

Sky Malice

unread,
May 18, 2026, 12:54:35 PM (4 days ago) May 18
to java, Sky Malice
Proposed update https://crrev.com/c/7855912

Nate Fischer

unread,
May 18, 2026, 1:14:05 PM (4 days ago) May 18
to Sky Malice, java, Sky Malice
I'm supportive. I think it's fair to call this out in the style guide.

I think there's a valid exception for when you have two classes with the exact same name. This is obviously pretty rare in our codebase, but I guess it's easy to acknowledge the carve-out.


Nate Fischer | Software Engineer | ntf...@google.com


--
You received this message because you are subscribed to the Google Groups "java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java+uns...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/java/bfb0e4c6-8281-4d1e-9304-66aa02be53f6n%40chromium.org.

Peter Birk Pakkenberg

unread,
May 19, 2026, 5:08:12 AM (4 days ago) May 19
to Nate Fischer, Sky Malice, java, Sky Malice
+1 - this seems like the least controversial style guide update (For humans, anyway) I have seen in a long time. 
I'm actually surprised that the LLMs even uses fully-qualified names. I wonder what code bases they were looking at to learn that?

Sincerely,
Google Logo
Peter Birk Pakkenberg
Software Engineer
pb...@google.com


Boris Sazonov

unread,
May 19, 2026, 8:01:29 AM (3 days ago) May 19
to Peter Birk Pakkenberg, Nate Fischer, Sky Malice, java, Sky Malice

Peter Wen

unread,
May 19, 2026, 10:01:03 AM (3 days ago) May 19
to Boris Sazonov, Peter Birk Pakkenberg, Nate Fischer, Sky Malice, java, Sky Malice
Reply all
Reply to author
Forward
0 new messages