Yarn: Drop 'get' prefix for methods

Created on 12 Dec 2019  ·  5Comments  ·  Source: FabricMC/yarn

Looking for feedback on this, as the standard libs seem to be no longer using get for their newer methods.

discussion refactor vote

Most helpful comment

I believe the JDK's standard is immutable is no prefix, while mutable is prefixed - this can somewhat be seen with the new records not having getters or setters as their data is immutable.

All 5 comments

So the current votes are 2 :+1: and 7 :-1:. Will take this as the result if there is no additional votes or comments in another 24 hours. Discord peeps mind take a look.

I support the change, but it needs some conventions written up as sometimes a get prefix is needed.

Ideally mirroring how the JDK approaches this.

Does jdk have get prefix when there is a setter? We might need to split these into when there is a setter vs when there is not.

For example, record getter methods don't have get prefixes, but they don't have setters and don't have potential name confusion.

In fact, some new jdk getters have get prefixes while others don't. A striking example is in java.lang.invoke.CallSite, introduced relatively recently in jdk 7, frequently used by invokedynamic bytecode instruction's bootstrap method attribute, where there is a MethodType type() getter and a MethodHandle getTarget() getter (the type one is immutable while the target one is mutable; there is a setTarget(MethodHandle) as well). Also some other newer apis use get prefix as well, such as Class.getModule from java 9.

I believe the JDK's standard is immutable is no prefix, while mutable is prefixed - this can somewhat be seen with the new records not having getters or setters as their data is immutable.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

copygirl picture copygirl  ·  6Comments

liach picture liach  ·  4Comments

Juuxel picture Juuxel  ·  5Comments

asiekierka picture asiekierka  ·  4Comments

Boundarybreaker picture Boundarybreaker  ·  3Comments