Style Guide Proposal: Ban Record Types

9 views
Skip to first unread message

Andrew Grieve

unread,
Oct 26, 2023, 10:35:06 AM10/26/23
to java, Peter Birk Pakkenberg
Proposed CL:
https://chromium-review.googlesource.com/c/chromium/src/+/4980185

Will give this until ~mid next week to see if anyone has comments:

Rationale:

  • To avoid dead code:
    • Records (like @AutoValue) generate equals()hashCode(), and toString(), which R8 is unable to remove when unused.
  • Supporting them requires build system work (crbug/1493366).

Nate Fischer

unread,
Oct 26, 2023, 1:03:11 PM10/26/23
to Andrew Grieve, java, Peter Birk Pakkenberg
I'm OK with this style guide change. I gave some optional wording suggestions on the CL, but I'm OK with this change as-is.

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 on the web visit https://groups.google.com/a/chromium.org/d/msgid/java/CABiQX1X5jArR78yoLmDvdkaOT86_1F8x_%2BO6LuRM-RpPGSd84g%40mail.gmail.com.

Andrew Grieve

unread,
Oct 27, 2023, 10:58:22 AM10/27/23
to Andrew Grieve, java, Peter Birk Pakkenberg
Since it's used as a reason to ban record types, I've also added a heading for toString():

toString()

Overriding toString() should not be done for debugging purposes, as the methods are not optimized out in release builds. It is encouraged to use custom methods (e.g. toDebugString() or getDescription()) when dynamic dispatch is not required.

Reply all
Reply to author
Forward
0 new messages