This is an automated archive made by the Lemmit Bot.

The original was posted on /r/java by /u/SaxSalute on 2024-09-26 15:17:41+00:00.


I’ve been writing Java since Java 7 and, at least before records, the only common convention for getters on data classes that I’d seen is getTheThing - “get” as a prefix, followed by what is being gotten in UpperCamelCase. I always liked having verbs in every method name since methods are doing something, even if just returning a value.

With the introduction of records though, there is a pretty heavy force towards just “theThing”. From a language design perspective, it’s obviously preferable not to try to parse language to include a prefix. I fully agree with how records handle accessor naming, but it’s also clearly different than the style most pre-records code uses.

This leads to a style question though - in a code base making heavy use of records, is the new accepted style to use un-prefixed naming for ALL getters? What about setters? I’m curious what other long-time Java developers have settled on with the addition of records.