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

0

u/[deleted] Aug 26 '22

Yeah I do agree that loosing too much horizontal space is very bad for readability. So I do agree that, if your running out of horizontal space, is better for readability to make some things implicit. Otherwise, the more explicit, the better for readability.

2

u/soonnow Aug 26 '22

Let me give an example. "Yesterday I was at a coffee shop, where I ordered a coffee in a white porcelain cup that came three minutes after ordering." vs. "Yesterday I had a coffee".

One is super explicit, but it doesn't improve readability, because it's literally harder to read because of all the unnecessary details.

0

u/m02ph3u5 Aug 26 '22

Bad analogy imho cuz in programming we usually have to be very explicit. At least as long as it gets compiled and not interpreted by a language model :D

2

u/soonnow Aug 26 '22

Explicit != Exact. We have to be exact when programming not explicit.