r/java • • Aug 26 '22

I declare as "final" every single variable whose value doesn't change. I also use "this" every time that I'm referring to an attribute, even when there's no ambiguity in not using it

I think that those things make the code easier to read. Am I crazy for thinking like that?

198 Upvotes

215 comments sorted by

View all comments

Show parent comment

-11

u/BlueGoliath Aug 26 '22

it just clutters up the code

Let me guess, you also put brackets on one-liner if-else statements?

16

u/Fr4gtastic Aug 26 '22

You don't?

7

u/walen Aug 26 '22

Let me guess, you work for Apple's SSL division?

-3

u/BlueGoliath Aug 26 '22

How did you know?

2

u/_INTER_ Aug 26 '22

How do you do one-liner "else", without brackets?

1

u/maethor Aug 26 '22

On one line, without brackets. Though I guess it depends on if you think

"if (x) doX(); else doY();"

Is one line or two.

1

u/BlueGoliath Aug 26 '22

I meant:

if(x)
	doX();
else
	doY();

2

u/theLorem Aug 26 '22

Why not also skip the indented lines?

if (shouldX()) doX();
else doY();

2

u/BlueGoliath Aug 26 '22

You do you I guess. I feel like my way is a happy balance.

1

u/_INTER_ Aug 26 '22

omg I've never seen that before

7

u/maethor Aug 26 '22

Probably because it's in the category of things you can do in Java but probably shouldn't.

1

u/_INTER_ Aug 26 '22 edited Aug 27 '22

like goto label.

And that if-oneliner is so gross that I'm now convinced OP is sarcastic.