vscode-java-code-generator icon indicating copy to clipboard operation
vscode-java-code-generator copied to clipboard

Require this in getters

Open haykam821 opened this issue 4 years ago • 1 comments

I would prefer the usage of this in getter code generation:

public int getWidth() {
    return this.width;
}

Could this be an option?

haykam821 avatar Oct 21 '21 00:10 haykam821

I dont know, but it generates my getters with "this" and I would prefer getter without "this" :D Maybe there could be some option to turn on or off "this" in getters?

pitris90 avatar Mar 08 '22 20:03 pitris90

for best practices it's not preferred in normal getters.

sohibegit avatar Apr 24 '23 00:04 sohibegit

for best practices it's not preferred in normal getters.

there is no set "best practice" for getters and setters, but I'd say it would make it clearer where that variable came from. Especially glancing over the thing without knowing exactly which fields are in the class, it'd be very helpful to at least know that the field being gotten belongs to this.

0x3C50 avatar Apr 24 '23 07:04 0x3C50